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

Facebook Graph API v2.4 #675

Closed
mashihill opened this issue Jul 10, 2015 · 25 comments
Closed

Facebook Graph API v2.4 #675

mashihill opened this issue Jul 10, 2015 · 25 comments

Comments

@mashihill
Copy link

Facebook updates it API recently,
it seems that the way to get extra scope is not working now.
e.g. setting SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
does not return the email.

here's the link to graph API v2.4
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/?ref=hp

@aisayko
Copy link

aisayko commented Jul 22, 2015

+1

2 similar comments
@highcat
Copy link

highcat commented Jul 24, 2015

+1

@scottlow
Copy link

+1

@highcat
Copy link

highcat commented Jul 26, 2015

I found solution:
now you need to request email field explicitly to retrieve it from Facebook, so just add this to your settings:

SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
    'fields': 'id,name,email', # needed starting from protocol v2.4
}

UP of course you need to set scope also:

SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] 

@christianmls
Copy link

Thanks for your solution.

How I can recover the email users who are already registered before the solution?

@aaj
Copy link

aaj commented Aug 14, 2015

Thanks highcat. Your solution seems to be working.

@macolo
Copy link

macolo commented Aug 15, 2015

Thanks!

1 similar comment
@po5i
Copy link

po5i commented Aug 19, 2015

Thanks!

@SalahAdDin
Copy link

👍 Put in docs please.

@romanovskiy-k
Copy link

Thanks! Please, update the docs.

@developcreativo
Copy link

and twitter? email = "" ?

@diegoponciano
Copy link

I tried setting SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS, didn't work for me.
Has the API been changed again?

@developcreativo
Copy link

If I work with facebook to twitter the issue is not cast me email

@Amar-Chaudhari
Copy link

I updated SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAM, but doesnt seem to work.
Do we need to update API version in https://github.com/omab/python-social-auth/blob/master/social/backends/facebook.py ?

@evcb
Copy link
Contributor

evcb commented Dec 14, 2015

SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS works for me on Facebook, but doesn't work for Twitter. Any ideas on how to get the e-mail?

@highcat
Copy link

highcat commented Dec 15, 2015

As I remember, there was NO way to get email from twitter, Twitter API won't return it (and everybody was frustrated about that).
Check it's API first, maybe things changed.

@evcb
Copy link
Contributor

evcb commented Dec 16, 2015

@highcat. I found this: http://stackoverflow.com/questions/22627083/can-we-get-email-id-from-twitter-oauth-api

It migh be worth trying. I have submitted a request. Let's see what happens.

@zixan
Copy link

zixan commented May 29, 2016

@christianmls the next time user logs in with facebook their email will be added to profile.

@PabloLefort
Copy link

PabloLefort commented Sep 28, 2016

Hi!
A work arround using Django 1.10, Python Social Auth 0.2.21 and Requests 2.11.1 to get email of user with facebook strategy:

@partial
def require_email(strategy, details, user=None, is_new=False, *args, **kwargs):
    if user and user.email:
        return
    elif is_new and not details.get('email'):
        if strategy.request_data().get('email'):
            details['email'] = strategy.request_data().get('email')
            return

        if strategy.request.session.get('email', '') != '':
            details['email'] = strategy.request.session['email']
            return

        fbuid = kwargs['response']['id']
        token = kwargs['response']['access_token']
        url = 'https://graph.facebook.com/{0}/?' \
              'fields=email&access_token={1}'.format(fbuid, token)
        resp = requests.get(url)
        if resp.json().get('email'):
            details['email'] = resp.json().get('email')
        else:
            return redirect('myapp:email-required')

And in settings:

SOCIAL_AUTH_PIPELINE = (
        #...
        'social.pipeline.social_auth.social_user',
        'myapp.pipeline.require_email'
        #...
)

@harunurkst
Copy link

It works for for facebook but not for LinkedIn. What is the solution for LinkedIn?

@PabloLefort
Copy link

@harun1393 Hi Harun, could you provide the stack trace?

@harunurkst
Copy link

Hi, My problem solved for LinkedIn also. I have done some mistake to write settings

@omab
Copy link
Owner

omab commented Dec 26, 2016

Facebook API is already updated, currently version is 2.8.

@omab omab closed this as completed Dec 26, 2016
@harunurkst
Copy link

harunurkst commented Dec 27, 2016 via email

@Cyxapic
Copy link

Cyxapic commented Oct 19, 2018

Hi, How get email in Facebook API v3.1?
Didnt work (((
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
'fields': 'id, name, email',
}

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