0

I had social_auth set up with facebook log-in for a Django app. However, recently it stopped working (even though I made no changes to the code as far as I recall). Before it worked fine, but now when I try to log in I get the following error from the Django debug screen that results: enter image description here

enter image description here

Through some further debugging I realized that the "response" variable in the facebook.py file when running the auth_complete function was non-empty, but then the parsed_response variable does not parse the response correctly and thus ends up empty. Thus in the facebook.py file of the social authentication backend, I changed the following line of code:

   parsed_response = cgi.parse_qs(response)

    access_token = parsed_response['access_token'][0]
    if 'expires' in parsed_response:
        expires = parsed_response['expires'][0]

To the following:

    import ast
    parsed_response = ast.literal_eval(response)

    access_token = parsed_response['access_token']
    if 'expires' in parsed_response:
        expires = parsed_response['expires']

And it works!

However, this seems like a hack to me. After scouring the web for people experiencing a similar problem with the social_auth login, I couldn't find any relevant posts. Similarly, it seems odd that it just stopped working all of a sudden as it was working this entire time. Thus, I feel like although this is a working solution, it is not the solution, as when I try to upload to Heroku or something that downloads and installs its own dependencies I will not be able to implement such a hack unless I make custom backend pipelines.

Maybe there is something obvious I am missing.

somil
  • 360
  • 6
  • 20
  • Please don't post screenshots. Copy and paste the traceback - it's more readable and makes it searchable for future visitors. – Alasdair May 17 '17 at 19:53
  • _“Similarly, it seems odd that it just stopped working all of a sudden as it was working this entire time.”_ – no, what’s odd is that so many people can’t be bothered to follow the announcements Facebook makes about such API changes way upfront. – CBroe May 18 '17 at 08:00

1 Answers1

0

It looks as if you have hit this issue. It appears to have been fixed in python-social-auth.

You have tagged your question django-social-auth, but it was deprecated in favour of python-social-auth. The current recommendation appears to be to install social-auth-core and the social-app-django app.

Alasdair
  • 298,606
  • 55
  • 578
  • 516