0

Wishing You a Happy New year I start with my first problem of the year

here's what I do in login method of user controller:

Yii::import('ext.eoauth.*');

            $ui = new EOAuthUserIdentity(
                            array(
                            //Set the "scope" to the service you want to use
                                            'scope'=>'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile',
                                            'provider'=>array(
                                                            'request'=>'https://www.google.com/accounts/OAuthGetRequestToken',
                                                            'authorize'=>'https://www.google.com/accounts/OAuthAuthorizeToken',
                                                            'access'=>'https://www.google.com/accounts/OAuthGetAccessToken',
                                            )
                            )
            );

            if ($ui->authenticate()) {
                    $user=Yii::app()->user;
                    $user->login($ui);
                    $this->redirect(array('loggedin'));
            }
            else 
                    throw new CHttpException(401, $ui->error);

its logged and in place of name it display the token key.. i need to get email at least to store it to db... Please help me out.. thanks in advance

sonorita
  • 771
  • 2
  • 8
  • 20

2 Answers2

0

In the UserIdentity class, You need to write a line i.e

$this->setState('name', 'value');

This is used to set the `Yii::app()->user->name so if you set it as

$this->setState('name', $record->email);
$this->errorCode=self::ERROR_NONE;

in your UserIdentity class then Yii::app()->user->name will return you the email or whatever you want

Let me see
  • 5,063
  • 9
  • 34
  • 47
  • Correct me if i am wrong ... In the example we are calling EOAuthUserIdentity class...we will not get any $record->email inside that.. Which value i need to set to name – sonorita Jan 02 '14 at 10:01
  • replace **$record->email** with the value you want to set. It was just an example – Let me see Jan 02 '14 at 10:05
0

I tried lot to get user detail by using above code.. Unfortunately I failed.. Then I started with eauth integration..I downloaded the demo example in the url and added extension to my extension folder inside protected and configured the main.php.. I got integration of more than 10 login integration.. I commented the services extension inside component tag in main.php to get Google and Yahoo login integration.. It works... Which made me to access the user name also.. Thanks for support..
demo of eauth

For integration find the link below Integration link for eauth

sonorita
  • 771
  • 2
  • 8
  • 20