Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
URLError at /social-auth/complete/facebook/ #315
Hi. I have some trouble with facebook backend. Also i've tried @krvss fork and got the same error. I see, almost all backends work fine (google-oauth2, instagram, flickr, vkontakte, yandex, ...), so it seems the reason is on my side.
Request Method: GET
Django Version: 1.4
Exception Type: URLError at /social-auth/complete/facebook/
I spent a long time trying to figure this one out - the url that the facebook.py code is trying to fetch there on line 100 is
Basically, it's the last step that the library tries to carry out in order to request a long term access token. When I printed that url out and went to it in my browser, it worked fine. The problem appears to be related to urllib2 and certain https websites.
We found that the problem exists with python 2.7.3 but not with python 2.7.1, so our ultimate solution was to throw up our hands and revert to 2.7.1. Not a very good solution - we should probably submit a patch to set up urllib2 correctly in facebook.py
Oh, I should also add - I see your python version is 2.7.2 above. Are you using the python from MacPorts? We found that python 2.7.2 revision 1 worked fine, but revision 4 did not, and I believe the version of openssl changed somewhere in between there, which was the ultimate cause of the problem.
FYI, I found a workaround for this issue. It works using the latest python version on mac - 2.7.3. At the top of my login handler (NOT facebook.py), before I load my login page - I run the following code taken from Ian Weatherbee on http://bugs.python.org/issue11220.
custom HTTPS opener, banner's oracle 10g server supports SSLv3 only
import httplib, ssl, urllib2, socket
This ensures that the sslv3 handler is installed before any other urllib2 code runs, which for me, fixes the issue coming from facebook.py.
@salomo851, i put that code into the top of my views, and it works fine! Thank you!
I use debian wheezy with python from repos, version is
Thanks again! I'll check if any other auth-backends work fine with this workaround.
vkontakte, twitter, mailru, google-oauth2, github, dropbox, linkedin, yandex, yahoo, instagram, flickr, foursquare works fine (i see, this check was not necessary, but %s). And also with fb-backend i got regirect back to
added a commit
Apr 15, 2012
I've added a comment about this issue in the docs http://django-social-auth.readthedocs.org/en/latest/miscellaneous.html#python-2-7-2rev4-2-7-3-and-facebook-backend. Thanks for the bug hunting and the detailed explanation.