我正在尝试使用http://code.google.com/p/oauth-python-twitter在appengine(python)中实现"twitter oauth" .
我使用以下代码将用户重定向到twitter:
twitter = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET) request_token = twitter.getRequestToken() response.set_cookie('request_token', request_token.to_string()) signin_url = twitter.getAuthorizationURL(request_token) return redirect_to(signin_url)
用户成功重定向,但当他在我的应用程序中返回时,我收到以下错误:HTTP错误401:未经授权
File "/base/data/home/apps/app/controllers/users.py", line 46, in authenticate access_token = twitter.getAccessToken() File "/base/data/home/apps/app/lib/python/oauthtwitter.py", line 183, in getAccessToken token = self._FetchUrl(url, no_cache=True) ...... File "/base/python_dist/lib/python2.5/urllib2.py", line 506, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
当我尝试获取访问令牌时发生错误.
request_token = request.cookies['request_token'] token = oauth.OAuthToken.from_string(request_token) twitter = OAuthApi(app_globals.CONSUMER_KEY, app_globals.CONSUMER_SECRET, token) # everything works good access_token = twitter.getAccessToken() # then, i receive the error.
任何的想法?谢谢!