Yii Framework Forum: [MODULE] HybridAuth - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[MODULE] HybridAuth Rate Topic: ***** 2 Votes

#41 User is offline   markvr 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 17-June 12

Posted 22 July 2012 - 05:33 PM

example config:
'modules'=>array(
		'hybridauth' => array(
			'baseUrl' => 'http://'. $_SERVER['SERVER_NAME'] . '/hybridauth', 
			'withYiiUser' => false,
			"providers" => array ( 
				"openid" => array (
					"enabled" => true
				),

				"yahoo" => array ( 
					"enabled" => true 
				),

				"google" => array ( 
					"enabled" => true,
					"keys"    => array ( "id" => "", "secret" => "" ),
					"scope"   => ""
				),

				"facebook" => array ( 
					"enabled" => true,
					"keys"    => array ( "id" => "", "secret" => "" ),

					// A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.fa...pi/permissions.
					"scope"   => "email", 

					// The display context to show the authentication page. Options are: page, popup, iframe, touch and wap. Read the Facebook docs for more details: http://developers.fa...ialogs#display. Default: page
					"display" => "" 
				),

				"twitter" => array ( 
					"enabled" => true,
					"keys"    => array ( "key" => "", "secret" => "" ) 
				)
			)
		),

0

#42 User is offline   M Wotton 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 01-November 09

Posted 23 July 2012 - 08:41 PM

A quick question - does this extension allow a single user to link multiple 3rd party providers to their account? Or are they forced to choose just one provider? Based on the page in the extensions directory, the table modification forces a user to have just one provider.

The ability to link multiple providers to a single user was one of the strengths of the Yii-auth implementation. Sampa did a great job, but the approach was messy. If this extension has multiple providers per user, then it will meet my requirements.
Micha Wotton
Posted Image
0

#43 User is offline   M Wotton 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 01-November 09

Posted 23 July 2012 - 08:44 PM

View PostM Wotton, on 23 July 2012 - 08:41 PM, said:

A quick question - does this extension allow a single user to link multiple 3rd party providers to their account? Or are they forced to choose just one provider? Based on the page in the extensions directory, the table modification forces a user to have just one provider.

The ability to link multiple providers to a single user was one of the strengths of the Yii-auth implementation. Sampa did a great job, but the approach was messy. If this extension has multiple providers per user, then it will meet my requirements.


You know, you can ignore that. I just refreshed the source page on github and see you have added a separate table - thus resolving the issue. Thanks.
Micha Wotton
Posted Image
0

#44 User is offline   valleed 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 16-July 12

Posted 23 July 2012 - 10:10 PM

Hi there,

Thanks for the feature for Yii User. I now get another error:

PHP warning

include(HaLogins.php): failed to open stream: No such file or directory

/home/something/yii/framework/YiiBase.php(418)

406                 {
407                     foreach(self::$_includePaths as $path)
408                     {
409                         $classFile=$path.DIRECTORY_SEPARATOR.$className.'.php';
410                         if(is_file($classFile))
411                         {
412                             include($classFile);
413                             break;
414                         }
415                     }
416                 }
417                 else
418                     include($className.'.php');
419             }
420             else  // class name with namespace in PHP 5.3
421             {
422                 $namespace=str_replace('\\','.',ltrim($className,'\\'));
423                 if(($path=self::getPathOfAlias($namespace))!==false)
424                     include($path.'.php');
425                 else
426                     return false;
427             }
428             return class_exists($className,false) || interface_exists($className,false);
429         }
430         return true;

Stack Trace
#0 	
+
 /home/something/yii/framework/YiiBase.php(418): YiiBase::autoload()
#1 	
 unknown(0): YiiBase::autoload("HaLogins")
#2 	
+
 /home/something/yii/framework/db/ar/CActiveRecord.php(378): spl_autoload_call("HaLogins")
#3 	
+
 /home/something/yii/framework/web/CActiveDataProvider.php(75): CActiveRecord::model("HaLogins")
#4 	
–
 /home/something/protected/modules/hybridauth/models/HaLogin.php(104): CActiveDataProvider->__construct("HaLogins", array("criteria" => CDbCriteria))

099         $criteria->compare('loginProvider',$loginProvider,true);
100         $criteria->compare('loginProviderIdentifier',$loginProviderIdentity,true);
101 
102         $login = new CActiveDataProvider('HaLogins', array(
103             'criteria'=>$criteria,
104         ));
105         
106         if ($login->itemCount == 0) {
107             return null;
108         } else {
109             // TODO - Can't seem to get this to work with relations properly....

#5 	
–
 /home/something/protected/modules/hybridauth/components/RemoteUserIdentity.php(43): HaLogin::getUser("Yahoo", "censored-url")

38         $adapter = $hybridauth->authenticate($this->loginProvider,$params);
39         if ($adapter->isUserConnected()) {
40             $this->_adapter = $adapter;
41             $this->loginProviderIdentifier = $this->_adapter->getUserProfile()->identifier;
42 
43             $user = HaLogin::getUser($this->loginProvider, $this->loginProviderIdentifier);
44             
45             if ($user == null) {
46                 $this->errorCode = self::ERROR_USERNAME_INVALID;
47             } else {
48                 $this->id = $user->id;

#6 	
–
 /home/something/protected/modules/hybridauth/controllers/DefaultController.php(44): RemoteUserIdentity->authenticate()

39         }
40         
41 
42         $identity = new RemoteUserIdentity($_GET['provider']);
43         
44         if ($identity->authenticate()) {
45             // They have authenticated AND we have a user record associated with that provider
46             if (Yii::app()->user->isGuest) {
47                 $this->_loginUser($identity);
48             } else {
49                 //they shouldn't get here because they are already logged in AND have a record for



If you need more informations, I will be happy to provide them.

Thanks again!
0

#45 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 24 July 2012 - 07:34 AM

View Postmarkvr, on 22 July 2012 - 05:28 PM, said:

A working version with multiple providers and support for YiiUser is up at https://github.com/markvr/hybridauth

It needs improving and more testing before updating the Yii exentension but if anyone is desperate for these features now then it's a start.

YiiUser Support:
You must have either NO config entries for YiiUser AND HybridAuth:withYiiUser config entry == false, OR the opposite.

i.e. what you mustn't do is HybridAuth:withYiiUser==false and also some config entries (e.g. imports etc) for YiiUser or vice versa. It will screw the autoloading up.


Kudos for putting it up on Github! :)
"Less noise - more signal"
0

#46 User is offline   markvr 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 17-June 12

Posted 24 July 2012 - 10:40 AM

View Postvalleed, on 23 July 2012 - 10:10 PM, said:

Thanks for the feature for Yii User. I now get another error:


HaLogin should be singular not plural, I wonder if the lines like
$login = new CActiveDataProvider('HaLogins', array(
			'criteria'=>$criteria,
		));


are wrong, but if so it wouldn't work at all, but it does work on my PC. Hmm, I might have some old detrius lying around that made it work on my PC but no one elses! This is why I haven't updated the Yii repo extension, what's on Github isn't properly tested yet.

I'll take a look and let you know.
cheers,
mark
0

#47 User is offline   valleed 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 16-July 12

Posted 24 July 2012 - 11:24 AM

Removing the S from HaLogins fixed it, thanks again!

The only thing bugging me now is getting the error message from the provider instead of:
 User profile request failed! Google returned an invalide response. 


Also, I have remove the strings firstname and lastname from the DefaultController, but that's just me.
0

#48 User is offline   markvr 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 17-June 12

Posted 24 July 2012 - 11:56 AM

View Postvalleed, on 24 July 2012 - 11:24 AM, said:

Removing the S from HaLogins fixed it, thanks again!

Yep, I had an old HaLogins model floating around which meant it worked on my PC. Fixed and updated Github

Quote

The only thing bugging me now is getting the error message from the provider instead of:
 User profile request failed! Google returned an invalide response. 



Don't know, I haven't tested with Google, there's only so many providers I can test with! Might be worth checking the HybridAuth docs on sourceforge.

Quote

Also, I have remove the strings firstname and lastname from the DefaultController, but that's just me.


Yeah that's a bit of a bodge but Yii User needs those entries filled in otherwise it bombs out when you view the profile. A better solution is going to be to fork the view that requests a username/email to include names as well if it's running in Yii User.
0

#49 User is offline   markvr 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 17-June 12

Posted 31 July 2012 - 02:39 PM

Updated the extension with multiple providers, and you can now also get the Hybrid_Auth class to write statuses to facebook etc.

See the extension for details.
0

#50 User is offline   Asterisk Pound 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 18-September 10

Posted 31 July 2012 - 06:58 PM

I'm curious if the RemoteUserIdentity property userData is just a general idea or if it's fully implemented yet.
0

#51 User is offline   Asterisk Pound 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 18-September 10

Posted 31 July 2012 - 07:34 PM

View PostAsterisk Pound, on 31 July 2012 - 06:58 PM, said:

I'm curious if the RemoteUserIdentity property userData is just a general idea or if it's fully implemented yet.


This seemed to make the most sense to me...

protected.modules.hybridauth.components.RemoteUserIdentity line 41 (function authenticate)
            $this->userData = $this->_adapter->getUserProfile();

0

#52 User is offline   markvr 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 17-June 12

Posted 01 August 2012 - 03:21 AM

View PostAsterisk Pound, on 31 July 2012 - 07:34 PM, said:

This seemed to make the most sense to me...

protected.modules.hybridauth.components.RemoteUserIdentity line 41 (function authenticate)
            $this->userData = $this->_adapter->getUserProfile();



The problem with that was you really need to put it into the session to use it in your controllers, but when PHP unserialised the session (at session_start()), because it couldn't autoload the Hybrid_Auth classes, it threw an error and died.

Doing:
$ha = Yii::app()->getModule('hybridauth')->getHybridAuth();

means that Hybrid_Auth gets init'd correctly, and you can then get the adapter directly from there, without needing to worry about manually loading all the Hybrid_Auth classes yourself, before session_start();
0

#53 User is offline   subdee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 24-January 11
  • Location:Den Haag

Posted 01 August 2012 - 04:43 AM

Hi,

I'm now trying out your module, and it works fine, but might I suggest you use the Yii::app()->createAbsoluteUrl() method to create the URLs because not everyone uses the urlManager the same way, and things might go wrong.
0

#54 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 01 August 2012 - 09:17 AM

View Postmarkvr, on 31 July 2012 - 02:39 PM, said:

Updated the extension with multiple providers, and you can now also get the Hybrid_Auth class to write statuses to facebook etc.

See the extension for details.

Good job.
1

#55 User is offline   pompey_pete 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 13-December 11

Posted 09 August 2012 - 04:58 AM

Firstly, thanks to markvr for excellent job on this extension!

Secondly, anyone know why twitter might not be working? Facebook works absolutely fine but when I try to use twitter an error stops the app. The error doesn't clear until I wipe the cookies to clear the session.

The error contains the following in stack trace:

–  /home/snowglo/public_html/protected/modules/hybridauth/Hybrid/Storage.php(25): unserialize("O:9:"Exception":7:{s:10:"*message";s:69:"Authentification fail...")


And the top message is:

include(DefaultController.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


DefaultController.php does exist so I can't explain why that's been reported, but the issue seems to be that twitter auth is failing and, despite double checking the public key and secret, I can't see why...

any ideas?
1

#56 User is offline   hakd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 11-August 12

Posted 11 August 2012 - 02:02 PM

View Postsubdee, on 01 August 2012 - 04:43 AM, said:

Hi,

I'm now trying out your module, and it works fine, but might I suggest you use the Yii::app()->createAbsoluteUrl() method to create the URLs because not everyone uses the urlManager the same way, and things might go wrong.


+1 for using more flexible url creation, it is not possible to use this extension when locale is part of the url.

Also, it will be nice to add support of CSRF.
It is possible to validate CSRF throuth GET parameter (see this solution)

Also, it will be good compatibility improvement to rewrite db table defination according to Yii db convention http://www.yiiframew...ention#database and update appropriate model class.

Quote

CREATE TABLE IF NOT EXISTS `ha_login` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`login_provider` varchar(50) NOT NULL,
`login_provider_identifier` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `login_provider_2` (`login_provider`,`login_provider_identifier`),
KEY `login_provider` (`login_provider`),
KEY `login_provider_identifier` (`login_provider_identifier`),
KEY `user_id` (`user_id`),
KEY `id` (`id`)
) ENGINE=InnoDB

1

#57 User is offline   univers3 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 06-July 12

Posted 14 August 2012 - 01:48 PM

Hi,
Nice addon.
But i have question:
Why, when an user accept the terms of the social network's application, you will ask username & email in the next step?
Is more better to let choose a password and a display name.
The email can be get in social account. or im wrong?
0

#58 User is offline   Fuentes 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-July 11

Posted 15 August 2012 - 02:14 PM

Using with the yii-user, I have to create the user name and enter the email. I could not do this automatically? The WP plugin to do. Thank you.
0

#59 User is offline   charmi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-August 12

Posted 19 August 2012 - 08:38 PM

Hello,
I have an issue. I am a new Yii user. I followed all the steps of the presentation page but I have an issue. When I click on Twitter or Facebook it redirect me to:
****://localhost:8084/hybridauth/default/login/?provider=facebook
Then I am getting a 404 error.
My config is:
'hybridauth' => array(
			'baseUrl' => '****://localhost:8084' . '/hybridauth',
			"providers" => array (

				"facebook" => array (
					"enabled" => true,
					"keys"    => array ( "id" => "AA", "secret" => "BB" ),
					"scope"   => "email,publish_stream",
					"display" => "Texte pour facebook"
				),

				"twitter" => array (
					"enabled" => true,
					"keys"    => array ( "key" => "AA", "secret" => "BB" )
				)
			)
        ),

I used **** because I cannot post links
0

#60 User is offline   charmi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-August 12

Posted 20 August 2012 - 05:52 AM

I think this is related to URL MANAGER
What should I do to fix this?

View Postcharmi, on 19 August 2012 - 08:38 PM, said:

Hello,
I have an issue. I am a new Yii user. I followed all the steps of the presentation page but I have an issue. When I click on Twitter or Facebook it redirect me to:
****://localhost:8084/hybridauth/default/login/?provider=facebook
Then I am getting a 404 error.
My config is:
'hybridauth' => array(
			'baseUrl' => '****://localhost:8084' . '/hybridauth',
			"providers" => array (

				"facebook" => array (
					"enabled" => true,
					"keys"    => array ( "id" => "AA", "secret" => "BB" ),
					"scope"   => "email,publish_stream",
					"display" => "Texte pour facebook"
				),

				"twitter" => array (
					"enabled" => true,
					"keys"    => array ( "key" => "AA", "secret" => "BB" )
				)
			)
        ),

I used **** because I cannot post links

0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users