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

Updae Facebook provider because they now return JSON for the access_token #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antoineleclair
Copy link

From their changelog:

[Oauth Access Token] Format - The response format of https://www.facebook.com/v2.3/oauth/access_token returned when you exchange a code for an access_token now return valid JSON instead of being URL encoded. The new format of this response is {"access_token": {TOKEN}, "token_type":{TYPE}, "expires_in":{TIME}}. We made this update to be compliant with section 5.1 of RFC 6749.

Otherwise the Facebook provider is now broken since they stopped supporting the old way.

@jenstroeger
Copy link
Collaborator

jenstroeger commented Nov 2, 2017

@antoineleclair Hello, it’s been a while!

The above fix today caused the following:

  File "/…/velruse/providers/facebook.py", line 121, in callback
    access_token = r.json()['access_token']
KeyError: 'access_token'

Looking at the response body though, r.json() gives me a dictionary of the following form:

{
    'access_token': 'EA…ZD',
    'token_type': 'bearer',
    'expires_in': 5180555
}

Should 'bearer' not be 'Bearer' though? When I use the following code, oddly enough it works:

rbody = r.json()
access_token = rbody['access_token']

@jenstroeger
Copy link
Collaborator

jenstroeger commented May 31, 2018

Also, FB URL has changed to https://www.facebook.com/v3.0/dialog/oauth. References see here and here.

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

Successfully merging this pull request may close these issues.

2 participants