简体   繁体   English

twitter登录:401客户端错误:需要授权

[英]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. 我正在使用python-social-auth在本地实现twitter登录,但我得到401客户端错误。 My django version is 1.6. 我的django版本是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. 文档中它建议安装ntp.I不知道如何安装ntp。

It turns out I left the callback url field blank in the twitter app console. 事实证明我在twitter app控制台中将回调url字段留空了。 Although, it's not required, but putting http://127.0.0.1:8000/complete/twitter/ (Note the slash at the end) did the job. 虽然,这不是必需的,但是把http://127.0.0.1:8000/complete/twitter/ (注意最后的斜线)完成了这项工作。

Note also that if you leave the final '/' off the end of the call back URL, you will get this error. 另请注意,如果将最后的“/”放在回调URL的末尾,则会出现此错误。 It should read 它应该读

http://127.0.0.1:8000/complete/twitter/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM