Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph api no email in access token

while using facebook graph api in authenticating a user, after successful login, i want to get the user email.

For this, i raised a request for user data: https://graph.facebook.com/me?access_token=xxxxxxxxxx

But for my surprise, i could not get user's email in json output... how can i get the email ? Do we need to specify any permissions ?

like image 208
shasi kanth Avatar asked Feb 10 '26 16:02

shasi kanth


2 Answers

You have to force it, like this:
...graph.facebook.com/me?**fields=email,name**&access_token...
Then you can use the object user->email

like image 154
Felipe Barth Avatar answered Feb 12 '26 16:02

Felipe Barth


Well yes you do need permission to grab someone's email although some people have their privacy set so that you can get their emails without this expressed permission, most don't.

The permissions need to be set under the login section (it depends on how you login as to how it is presented, so I can't really help you out there unless I have more info).

'user_about_me' is the user permission that you probably already have but you need 'email' to get their primary email.

More information on the permissions for facebook developers can be found here.

I hope this has helped!

Best of luck,

Jon

like image 31
BetaPAWDkitsune Avatar answered Feb 12 '26 15:02

BetaPAWDkitsune



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!