amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

I can't get the user's eMail from a succesfull facebook's login #153

Open famigone opened 8 years ago

famigone commented 8 years ago

In the user table, email column is empty, the rest it's fine. This is my web.php configuration:

           'facebook' => [
                'class' => 'yii\authclient\clients\Facebook',
                'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',     
                'clientId' => '15805XXXXXXXXXXXX',
                'clientSecret' => '8c76YYYYYYYYYYYYYYYYYYYYYY',
                'scope' => 'email',
            ],

I even can see the facebook's oAuth pop up, where i accept the email permission.

amnah commented 8 years ago

that means the user doesn't have an email. they probably signed up with a phone number On May 26, 2016 10:23 AM, "cognitivaxx" notifications@github.com wrote:

In the user table, email column is empty, the rest it's fine. This is my web.php configuration:

'facebook' => [ 'class' => 'yii\authclient\clients\Facebook', 'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup', 'clientId' => '1580509622246199', 'clientSecret' => '8c7654172fea1bb66e81834a7042e647', 'scope' => 'email', ],

I even can see the facebook's oAuth pop up, where i accept the email permission.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/amnah/yii2-user/issues/153

famigone commented 8 years ago

I've checked it, even email duplicated but don't. The FB user was created with email, and that email did not previously exist in the database.

In auth_ket table, provider_attributes column i have this: {"name":"John Lee","id":"1XXXXXXXXXXXX"}

amnah commented 8 years ago

Then I don't know. You'll have to dump the data you get from facebook and check if you're actually getting an email.

https://github.com/amnah/yii2-user/blob/master/controllers/AuthController.php#L239-L241

print_r($attributes);
exit;
famigone commented 8 years ago

Yes, it seems like i am not reciving email from FB:

Array ( [name] => John Lee [id] => 11XXXXXXXXXXX )

That's weird...

famigone commented 8 years ago

Well, it seems there may be many reasons, in accordance with Facebook's boys:

amnah commented 8 years ago

Hmmm ... is it possible that the first time you authenticated, it didn't ask for email permission? Then the next time you changed the scope to ask for email, but because you didn't allow it the first time it doesn't send it.

Or would it ask you to to re-authorize because of different permissions?