[英]Missing OAuth request token cookie error using tornado and TwitterMixin
I'm using tornado and the TwitterMixin and I use the following basic code:我正在使用 tornado 和 TwitterMixin,并使用以下基本代码:
class OauthTwitterHandler(BaseHandler, tornado.auth.TwitterMixin):
@tornado.web.asynchronous
def get(self):
if self.get_argument("oauth_token", None):
self.get_authenticated_user(self.async_callback(self._on_auth))
return
self.authorize_redirect()
def _on_auth(self, user):
if not user:
raise tornado.web.HTTPError(500, "Twitter auth failed")
self.write(user)
self.finish()
For me it works very well but sometimes, users of my application get a 500 error which says: Missing OAuth request token cookie对我来说它工作得很好,但有时,我的应用程序的用户会收到 500 错误,上面写着: Missing OAuth request token cookie
I don't know if it comes from the browser or the twitter api callback configuration.不知道是来自浏览器还是twitter api回调配置。 I've looked through the tornado code and I don't understand why this error appears.
我查看了龙卷风代码,但我不明白为什么会出现此错误。
Two reasons why this might happen:可能发生这种情况的两个原因:
oauth_token
argument is set, but the cookie is not.oauth_token
参数,但未设置 cookie。 Not sure why this would happen, you'd have to log some logging to understand why. At any rate, this isn't an "error," but rather a sign the user isn't authenticated.无论如何,这不是“错误”,而是用户未通过身份验证的标志。 Maybe if you see that you should just redirect them to the authorize URL and let them try again.
也许如果您看到您应该将它们重定向到授权 URL 并让他们再试一次。
I found the solution !!我找到了解决方案!
It was due to my DNS.这是由于我的 DNS。
I didn't put the redirection for www.mydomain.com and mydomain.com so sometimes the cookie was set in www.我没有为 www.mydomain.com 和 mydomain.com 设置重定向,所以有时 cookie 设置在 www. and sometimes not then my server didn't check in the good place, didn't find the cookie and then send me a 500 error.
有时不是,然后我的服务器没有检查好地方,没有找到 cookie,然后向我发送 500 错误。
The reason this was happening to me is that the Callback URL configuration was pointing to a different domain.这发生在我身上的原因是回调 URL 配置指向不同的域。
Take a look at the settings tab for your application at https://dev.twitter.com/apps/ or if the users getting the error are accessing your site from a different domain.在https://dev.twitter.com/apps/中查看您的应用程序的设置选项卡,或者如果收到错误的用户正在从不同的域访问您的站点。
See: http://groups.google.com/group/python-tornado/browse_thread/thread/55aa42eef42fa1ac请参阅: http://groups.google.com/group/python-tornado/browse_thread/thread/55aa42eef42fa1ac
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.