Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitter login: 401 Client Error: Authorization Required

I'm using python-social-auth to implement twitter login locally but I get the 401 client error. My django version is 1.6.

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  45.             return func(request, backend, *args, **kwargs)
File "/Library/Python/2.7/site-packages/social/apps/django_app/views.py" in auth
  12.     return do_auth(request.social_strategy, redirect_name=REDIRECT_FIELD_NAME)
File "/Library/Python/2.7/site-packages/social/actions.py" in do_auth
  25.     return strategy.start()
File "/Library/Python/2.7/site-packages/social/strategies/base.py" in start
  66.             return self.redirect(self.backend.auth_url())
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in auth_url
  99.         token = self.set_unauthorized_token()
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in set_unauthorized_token
  158.         token = self.unauthorized_token()
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in unauthorized_token
  177.                                 method=self.REQUEST_TOKEN_METHOD)
File "/Library/Python/2.7/site-packages/social/backends/base.py" in request
  205.         response.raise_for_status()
File "/Library/Python/2.7/site-packages/requests/models.py" in raise_for_status
  808.             raise HTTPError(http_error_msg, response=self)

Exception Type: HTTPError at /login/twitter/
Exception Value: 401 Client Error: Authorization Required

In documentation it suggests to install ntp.I have no clue how to install ntp.

like image 747
James L. Avatar asked Feb 11 '23 23:02

James L.


2 Answers

It turns out I left the callback url field blank in the twitter app console. Although, it's not required, but putting http://127.0.0.1:8000/complete/twitter/ (Note the slash at the end) did the job.

like image 194
James L. Avatar answered Feb 14 '23 13:02

James L.


Note also that if you leave the final '/' off the end of the call back URL, you will get this error. It should read

http://127.0.0.1:8000/complete/twitter/
like image 27
MagicLAMP Avatar answered Feb 14 '23 13:02

MagicLAMP