tschellenbach / Django-facebook

Facebook open graph api implementation using the Django web framework in python
http://www.mellowmorning.com/
Other
1.43k stars 543 forks source link

Exception when "Remove offline_access permission" is activate #215

Closed BenoitNorrin closed 11 years ago

BenoitNorrin commented 12 years ago

When "Remove offline_access permission" is activate (will be by default on 5/12/12), facebook does not return "expires" .

We got an exception on the first authentication, and only on first :

MultiValueDictKeyError: "Key 'expires' not found in <QueryDict: {u'access_token': [u'AAAFZBuMLWY1IBANsDVX...ZDZD']}>"

Your application > Modify > Advanced > Migrations https://developers.facebook.com/roadmap/#offline-access-removal

tschellenbach commented 12 years ago

I have that enabled for quite some time now. Do you have a stacktrace for me?

tschellenbach commented 12 years ago

By the way, be sure that you're running the latest version of Django Facebook. It automatically extends your tokens, which is important if you're coming from an offline access setup.

BenoitNorrin commented 12 years ago

Yes, latest version. Here more informations. This is append only on first user connection. As you can see, there is no "expires" in facebook response.

INFO requesting url https://graph.facebook.com/oauth/access_token?client_secret=3d000900000352f6&grant_type=fb_exchange_token&client_id=42080690000030&fb_exchange_token=AAAFZBuMLWY1IBAATQ81jRNZCMV7jd6n3tE4vy8e0K3lyFRYyAkRDugu8WrhWUktc6ZBhJlzwZDZD with post data None
INFO facebook send response <QueryDict: {u'access_token': [u'AAAFZBuMLWY1IBANsDVX14ZBGTDXCt5mNZCMV7jd6n3tE4vy8e0K3lyFRYyAkRDugu8WrhWUktc6ZBhJlzwZDZD']}>
ERROR Internal Server Error: /facebook/connect/
Traceback (most recent call last):
  File "/path/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/path/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 77, in wrapped_view
    return view_func(*args, **kwargs)
  File "/path/django-facebook/django_facebook/decorators.py", line 95, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/path/django-facebook/django_facebook/views.py", line 92, in connect
    response = _connect(request, facebook_login)
  File "/path/django-facebook/django_facebook/views.py", line 130, in _connect
    action, user = connect_user(request)
  File "/path/django-facebook/django_facebook/connect.py", line 94, in connect_user
    _update_access_token(user, graph)
  File "/path/django-facebook/django_facebook/connect.py", line 170, in _update_access_token
    profile.extend_access_token()
  File "/path/django-facebook/django_facebook/models.py", line 87, in extend_access_token
    results = self._extend_access_token(self.access_token)
  File "/path/django-facebook/django_facebook/models.py", line 94, in _extend_access_token
    results['expires'])
  File "/path/lib/python2.7/site-packages/django/utils/datastructures.py", line 258, in __getitem__
    raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
MultiValueDictKeyError: "Key 'expires' not found in <QueryDict: {u'access_token': [u'AAAFZBuMLWY1IBANsDV..YyAkRDugu8WrhWUktc6ZBhJlzwZDZD']}>"
chrisfranklin commented 12 years ago

I am also receiving this error, did anyone find out more?

Ninja edit: I believe I have fixed the issue, code is available at https://github.com/PageHub/Django-facebook/commit/089635e2a4322c5e5332112235d0b0fc09f29f0b

chrisfranklin commented 12 years ago

Can somebody confirm this issue is fixed so that we can close it? Cheers