Search code examples
djangogoogle-app-enginepython-social-authdjangoappengine

python-social-auth failure on Google App Engine


I am attempting to follow Tutorial: Adding Facebook/Twitter/Google Authentication to a Django Application. The only thing I am doing differently is that I am running DjangoAppEngine on the Google App Engine development server, otherwise everything is exactly as per the tutorial.

When I get to Step 4 and actually try to authenticate with Facebook, I am getting a runtime error:

error('illegal IP address string passed to inet_pton',)

Request Method: GET
Request URL:    http://localtest.com:8080/o/complete/facebook/?redirect_state=FG4K...UG1k
Django Version: 1.6.11
Exception Type: RuntimeError
Exception Location: /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py in _MakeRealSyncCall, line 235
Python Executable:  /usr/local/opt/python/bin/python2.7
Python Version: 2.7.11

Obviously FB is passing an approval back to my app, as the request URL includes the callback path.

It appears that something in the GoogleAppEngineLauncher is trying to look up an address and is not receiving the right data in? I'm not really sure.

In trying to resolve this, I've come across a single comment somewhere suggesting to a user that SimpleAuth might be a better way to go, but I don't understand why and I'm not really sure I want to start over if I am just missing something obvious.

Does anyone know why I am getting this error and what I can do to correct it?


Solution

  • 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).