Skip to content

Commit

Permalink
fix response not header on get access token
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio.dzul committed Nov 3, 2017
1 parent 4db9efc commit c50302f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyfb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import auth
from urlparse import parse_qsl
from utils import Json2ObjectsFactory

import json
class FacebookClient(object):
"""
This class implements the interface to the Facebook Graph API
Expand Down Expand Up @@ -135,12 +135,12 @@ def get_access_token(self, app_secret_key, secret_code, redirect_uri):
url = "%s%s" % (self.BASE_TOKEN_URL, url_path)

data = self._make_request(url)

data = json.loads(data)
if not "access_token" in data:
ex = self.factory.make_object('Error', data)
raise PyfbException(ex.error.message)

data = dict(parse_qsl(data))
# data = dict(parse_qsl(data))
self.access_token = data.get('access_token')
self.expires = data.get('expires')
return self.access_token
Expand Down

1 comment on commit c50302f

@jmg
Copy link
Owner

@jmg jmg commented on c50302f Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergioDzul Thanks for the fix! Looks pretty neat.
However I'm not sure if Facebook responds with the old string access_token=[[token]] if you are using older versions of the api. Could you just wrap the data = json.loads(data) in a try except block so we make sure it keeps the backguard compatibility? Thanks!

Please sign in to comment.