Skip to content

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