omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

Facebook url versions should be configurable #926

Closed troygrosfield closed 7 years ago

troygrosfield commented 8 years ago

The facebook url [1] version should be configurable since most users will eventually want to upgrade:

class FacebookOAuth2(BaseOAuth2):
    """Facebook OAuth2 authentication backend"""
    AUTHORIZATION_URL = 'https://www.facebook.com/v2.3/dialog/oauth'
    ACCESS_TOKEN_URL = 'https://graph.facebook.com/v2.3/oauth/access_token'
    REVOKE_TOKEN_URL = 'https://graph.facebook.com/v2.3/{uid}/permissions'
    USER_DATA_URL = 'https://graph.facebook.com/v2.3/me'

Should be something like:

fb_api_version = settings.SOCIAL_AUTH_FACEBOOK_API_VERSION

class FacebookOAuth2(BaseOAuth2):
    """Facebook OAuth2 authentication backend"""
    AUTHORIZATION_URL = 'https://www.facebook.com/{0}/dialog/oauth'.format(fb_api_version)
    ACCESS_TOKEN_URL = 'https://graph.facebook.com/{0}/oauth/access_token'.format(fb_api_version)
    REVOKE_TOKEN_URL = 'https://graph.facebook.com/{0}/{uid}/permissions'.format(fb_api_version)
    USER_DATA_URL = 'https://graph.facebook.com/{0}/me'.format(fb_api_version)

I guess the problem here is that the code handling of the api responses might need to change as well though.

UPDATE: the comments below were related to changing my email in facebook, then trying to login via facebook which was linked to another account. The error I was seeing was my fault.

Also, I came across an issues where a single facebook user can have multiple facebook uids if auth is handled across multiple apps:

IE, a facebook UID is not always the same. I ran into an issue where my fb user id that was stored was different when I released a mobile app so I could no longer authenticate my facebook user. I was unaware that a single facebook user could have multiple facebook user ids until today.

[1] https://github.com/omab/python-social-auth/blob/master/social/backends/facebook.py

c-bata commented 8 years ago

+1

omab commented 7 years ago

I've added support for it in social-core, and documented in social-docs.