markvr
(Markvanrossum)
July 22, 2012, 10:33pm
41
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.facebook.com/docs/reference/api/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.facebook.com/docs/reference/dialogs#display. Default: page
"display" => ""
),
"twitter" => array (
"enabled" => true,
"keys" => array ( "key" => "", "secret" => "" )
)
)
),
mwotton
(Micha Wotton)
July 24, 2012, 1:41am
42
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.
mwotton
(Micha Wotton)
July 24, 2012, 1:44am
43
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.
valleed
(Davidvd+Yii)
July 24, 2012, 3:10am
44
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!
jacmoe
(Jacob Moena)
July 24, 2012, 12:34pm
45
markvr:
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!
markvr
(Markvanrossum)
July 24, 2012, 3:40pm
46
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
valleed
(Davidvd+Yii)
July 24, 2012, 4:24pm
47
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.
markvr
(Markvanrossum)
July 24, 2012, 4:56pm
48
Yep, I had an old HaLogins model floating around which meant it worked on my PC. Fixed and updated Github
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.
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.
markvr
(Markvanrossum)
July 31, 2012, 7:39pm
49
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.
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();
markvr
(Markvanrossum)
August 1, 2012, 8:21am
52
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();
subdee
(Subdivizion)
August 1, 2012, 9:43am
53
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.
ee0pdt
(Junk)
August 9, 2012, 9:58am
55
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?
hakd
(Konstantin D A)
August 11, 2012, 7:02pm
56
subdee:
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.yiiframework.com/doc/guide/1.1/en/basics.convention#database and update appropriate model class.
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
univers3
(Damianoher)
August 14, 2012, 6:48pm
57
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?
fuentes
(Cadastros)
August 15, 2012, 7:14pm
58
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.
charmi
(Chermi Ma)
August 20, 2012, 1:38am
59
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
charmi
(Chermi Ma)
August 20, 2012, 10:52am
60
I think this is related to URL MANAGER
What should I do to fix this?
charmi:
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