Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the email through facebook login? #70

Closed
wingchen opened this issue May 19, 2011 · 2 comments
Closed

How do I get the email through facebook login? #70

wingchen opened this issue May 19, 2011 · 2 comments

Comments

@wingchen
Copy link

Thank you all for coming up with this wonderful app. It's really cool! However, please allow me to post a question here, since I don't know a better place to shoot this question.

I am using django-social-auth with my authentication mechanism of my application. In other parts of my app, I need the email from the logged-in user for certain features. I do not have any problem with Google and Yahoo. However, when it comes to facebook, I could not gain the user email from reques.user. Could you please tell me where I will be able to get the user email?

Here comes my code to get the user info. Thank you very much.

 '''
 Gets the basic user information from the system.
 '''
 def getDjangoDefaultUserInfo(request):
     email = ''
     provider = None
     user_name = request.user.username
     provider_string = ''
     if user_name != '':
         email = request.user.email
         provider = request.user.social_auth.values_list('provider', flat=True)
         for name in provider:
             provider_string += name.lower().replace('-', '_')

     info = {
         'user_name' : user_name,
         'email' : email,
         'provider' : provider_string
     }
     return info
@omab
Copy link
Owner

omab commented May 19, 2011

You need to specify "email" scope to Facebook backend, add this setting::

FACEBOOK_EXTENDED_PERMISSIONS = ['email']

that should be enough to get user email populated properly.

@omab omab closed this as completed May 19, 2011
@wingchen
Copy link
Author

Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants