Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPError at /complete/facebook/ when trying to connect to Facebook. #207

Closed
psych0der opened this issue Mar 5, 2014 · 13 comments
Closed

Comments

@psych0der
Copy link

I am keep getting this 400 Client Error: Bad Request whenever I try to connect to Facebook through python social auth. I have entered correct parameter in Facebook app settings ( localhost:8000 as site URL).

Here's the exception stack :

HTTPError at /complete/facebook/
400 Client Error: Bad Request
Request Method: GET
Request URL: http://localhost:8000/complete/facebook/?redirect_state=znj2c5EEL42tSm7bteQF2HtgOFyDKEDD&code=AQBeVfYEcNM6ehAVgfOLx3B1GHEu48-V8zRh8l-pLvo8Kn43_x85XvFwVDsXsG1i7UWoA56zgbPNKmCMS7veZV85aamR_unPH1lTGmI3H18tf_CiAuLP9kMyDdeumIPtQeIkOnSO6BCivIVfp1TwezoQlpR8Dwksh8aZ389GzEcXeAhf28fzWU9YYs52sIg8zbJ-CQjFk18igGrpj0Iz4Agzxe1LyaiYtOAB8wxkzbfgVYm7s9FBYSKZ-Y0O5OiNTx5-8t0fEcYs2tu2YwssP9A6nXyM58bLWZmVyFZqmbILJxI8yP-dbJ_SkWn0sVFUVxc&state=znj2c5EEL42tSm7bteQF2HtgOFyDKEDD
Django Version: 1.5.5
Exception Type: HTTPError
Exception Value:
400 Client Error: Bad Request
Exception Location: /Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/requests/models.py in raise_for_status, line 773
Python Executable: /Users/mayankbhola/nobles0ul_progr/venvs/resumizr/bin/python
Python Version: 2.7.6
Python Path:
['../..',
'/Users/mayankbhola/Downloads/python-social-auth-master/examples/django_example',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/mongoengine-0.8.7-py2.7.egg',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/pymongo-2.6.3-py2.7-macosx-10.9-x86_64.egg',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python27.zip',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/plat-darwin',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/plat-mac',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/lib-tk',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/lib-old',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/lib-dynload',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages']
Server time: Wed, 5 Mar 2014 08:00:44 -0200

@omab
Copy link
Owner

omab commented Mar 5, 2014

Could you paste the full traceback? I wan't to see the calls chain.

@psych0der
Copy link
Author

Environment:

Request Method: GET
Request URL: http://localhost:8000/complete/facebook/?redirect_state=i6irPGAcgPVjkkMER4qk2UnBXrmtvFfo&code=AQDtYMNBz-4OVB5LpjIXQMxlsBMYI1OxOfbMGa_AqYv6bn8AaP_Sjb1_PwwJdKoqDej7-5A7YdsNAJT0d9U41et-5mH7ui0gmkLZkxfcWAE0M27aPmqOkj_hmQpsIicRg_kZQulNUQ5fE736B5WSiaXGf3GfwXJkYwhfIq7y1szTUvzwXfw1wqKf1QpC9MRTOhFeplWYP774NAjPAtznay9OAQ55pOrQIdO4y1bGhVb39i7eoubOMiQVZadrqWko-vDrZx5_ulioFRaS5KCKAKYVCuM4Qq8cx-940j-E2X5N85E3_5bH0HrmC7FkSQGYJQ4&state=i6irPGAcgPVjkkMER4qk2UnBXrmtvFfo

Django Version: 1.5.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'social.apps.django_app.default',
'example.app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  2.     return view_func(_args, *_kwargs)
    
    File "../../social/apps/django_app/utils.py" in wrapper
  3.         return func(request, backend, _args, *_kwargs)
    
    File "../../social/apps/django_app/views.py" in complete
  4.                    redirect_name=REDIRECT_FIELD_NAME, _args, *_kwargs)
    
    File "../../social/actions.py" in do_complete
  5.                              _args, *_kwargs)
    
    File "../../social/strategies/base.py" in complete
  6.     return self.backend.auth_complete(_args, *_kwargs)
    
    File "../../social/backends/facebook.py" in auth_complete
  7.         'code': self.data['code']
    
    File "../../social/backends/base.py" in get_querystring
  8.     return parse_qs(self.request(url, _args, *_kwargs).text)
    
    File "../../social/backends/base.py" in request
  9.     response.raise_for_status()
    
    File "/Users/mayankbhola/nobles0ul_progr/venvs/resumizr/lib/python2.7/site-packages/requests/models.py" in raise_for_status
  10.         raise HTTPError(http_error_msg, response=self)
    

Exception Type: HTTPError at /complete/facebook/
Exception Value: 400 Client Error: Bad Request

@omab
Copy link
Owner

omab commented Mar 5, 2014

Thanks, one last value, try getting the URL that's trying to open (it should start with https://graph.facebook.com/oauth/access_token), you should be able to get it by checking the vars values in one of those last calls in the traceback. This will allow me to identify the values being sent and the probably cause of that 400 error, which usually is caused by a empty secret key or another missing parameter required by facebook.

@psych0der
Copy link
Author

url
'https://graph.facebook.com/oauth/access_token'
self
<social.backends.facebook.FacebookOAuth2 object at 0x10be3b210>
args
()
response
<Response [400]>
kwargs
{'params': {'client_id': 'XXXXXXXXXXXXXXXXXX',
'client_secret': 'XXXXXXXXXXXXXXXXXX',
'code': u'AQDr2cSh0ssAMTh02mINqzO7ucqJxORlTpQ7pcvaJq3_Ncz59Qc2MAhn4Ns3gqGnD169Qgn6YANwKfTUshK1XWSXNWwCFmU7g0BXKhR1vAGFiOcuO1Fj4um6zmBDfptS7TW1yUmJHh9kHaLIhqYYqbe3Jfty5SRO7zx7v8-Fqd5A0giNu1IkKbJreC_1JjPj_0b8mu5I-Sv5v0V4V3bV4ZBFsPJT7Y-CC70rFDFEi4dxp-rsQlTonbcR3A9iswmwBeeKfbuyfNU2epBihuBxZ0SJI-vzb0oNGBjHzcSwbx8CRTn21ytzV1KYO5jH1qHzt4U',
'redirect_uri': 'http://localhost:8000/complete/facebook/?redirect_state=i6irPGAcgPVjkkMER4qk2UnBXrmtvFfo'},
'timeout': None}
method
'GET'

@psych0der
Copy link
Author

Did previous value of any use ?

@omab
Copy link
Owner

omab commented Mar 10, 2014

It did and looks like the server request is OK, I'm still trying to figure out were it's breaking.

@psych0der
Copy link
Author

ok thanx

On 10 March 2014 23:01, Matías Aguirre notifications@github.com wrote:

It did and looks like the server request is OK, I'm still trying to figure
out were it's breaking.

Reply to this email directly or view it on GitHubhttps://github.com//issues/207#issuecomment-37209928
.

Regards
Mayank Bhola

@omab
Copy link
Owner

omab commented Mar 15, 2014

@psych0der, I'm still unable to reproduce the issue, I've created a new Facebook application from scratch, filled all the values and it worked, in the process I've noticed that Facebook doesn't allow localhost as App Domains anymore. Also tried my usual app (which is quite old) and it works as expected too.

I'm gonna keep looking but could you try with a new application and provide some example code to reproduce the issue?

@psych0der
Copy link
Author

@omab, thanx for that. I tried example app bundled with python social auth
for django and filled in Facebook details.

Can you please re mention Facebook details which I need to fill in while
regestering new app? And is there no way I can test it with local host?

On Saturday, March 15, 2014, Matías Aguirre notifications@github.com
wrote:

@psych0der https://github.com/psych0der, I'm still unable to reproduce
the issue, I've created a new Facebook application from scratch, filled all
the values and it worked, in the process I've noticed that Facebook doesn't
allow localhost as App Domains anymore. Also tried my usual app (which is
quite old) and it works as expected too.

I'm gonna keep looking but could you try with a new application and
provide some example code to reproduce the issue?

Reply to this email directly or view it on GitHubhttps://github.com//issues/207#issuecomment-37718476
.

Regards
Mayank Bhola

@omab
Copy link
Owner

omab commented Mar 15, 2014

@psych0der, there were the details I needed to fill:

  1. Display Name and Category (popup when clicking Create a New App from the menu)
  2. In Settings -> Basic fiilled
    • App Domains: myapp.com
    • Clicked Add Platform and selected Website
      • Set Site URL to http://myapp.com:8000/
  3. In Settings -> Advanced
    • Ensured that Client OAuth Login is on
    • Ensured that Native or desktop app? is off

Finally copied App ID (filled SOCIAL_AUTH_FACEBOOK_KEY) and App Secret (filled SOCIAL_AUTH_FACEBOOK_SECRET).

@psych0der
Copy link
Author

Thanx a lot @omab. The issue was, I had registered app using localhost as
siteurl (http://localhost:8000).
I think this should be mentioned in the documentation to not to use
localhost while registering the app.

Thanx again :)

On 15 March 2014 12:07, Matías Aguirre notifications@github.com wrote:

@psych0der https://github.com/psych0der, there were the details I
needed to fill:

  1. Display Name and Category (popup when clicking Create a New Appfrom the menu)
  2. In Settings -> Basic fiilled
    • App Domains: myapp.com
    • Clicked Add Platform and selected Website
    • Ensured that Client OAuth Login is on
    • Ensured that Native or desktop app? is off

Finally copied App ID (filled SOCIAL_AUTH_FACEBOOK_KEY) and App Secret(filled
SOCIAL_AUTH_FACEBOOK_SECRET).

Reply to this email directly or view it on GitHubhttps://github.com//issues/207#issuecomment-37718827
.

Regards
Mayank Bhola

@omab omab closed this as completed in bf6edaa Mar 15, 2014
@omab
Copy link
Owner

omab commented Mar 15, 2014

I've changed the docs at http://psa.matiasaguirre.net/docs/backends/facebook.html

Thanks!

@alexche8
Copy link

I got same issue with steam .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants