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:
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.