[Answered ]-Python-social-auth failure on Google App Engine

1👍

UPDATE: the original answer (starting with ‘HOWEVER’) is no longer necessary, just use requests 2.10.0 or above, urllib3 1.15.1 or above, and requests_toolbelt 0.6.2 or above and perform the following in your main():

from requests_toolbelt.adapters import appengine
appengine.monkeypatch()

HOWEVER if you’re using older versions of requests and/or urllib3, then you need the patches below:

This can be accomplished using a patched version of requests along with the requests-toolbelt package. Threads that apply:

I’ve applied all of this and now have python-social-auth and facebook-sdk working in both local test (the dev server) and production (full App Engine).

1👍

It happens because the Facebook SDK depends on the awesome requests library. However, requests doesn’t work on Google App Engine since the platform has some restrictions. You have to use their urlfetch APIs to fetch external contents on Google App Engine.

So yes, the official Facebook SDK won’t work. You have to roll your own solution or find one that works. SimpleAuth is one of the solution that is known to have worked.

👤masnun

0👍

In your vendored libraries, ensure that you have requests_toolbelt. (pip install -t lib requests_toolbelt). Then “monkeypatch” appengine support before python-social-auth ever calls requests. In my project/wsgi.py, I added the following lines:

from requests_toolbelt.adapters import appengine
appengine.monkeypatch()

python-social-auth depends on requests, so it should also exist in your vendor directory.

You must also ensure you are using requests version >= 2.10.0. This has not been released yet, so you can fake it. Edit lib/requests/__init__.py so that __build__ = 0x021000. You also must upgrade the packaged version of urllib3 in the lib/requests/packages/ directory to the latest version.

This is what worked for me.

👤kzh

Leave a comment