【发布时间】:2015-06-02 21:28:22
【问题描述】:
我正在尝试使用 Tweepy 在 Django 中设置 oauth。我收到以下错误。
/auth/处的AttributeError
'dict'对象没有属性'key'
当用户被转发到回调 url (http://localhost:8000/callback) 时,当我尝试存储请求令牌以供以后访问时,会在以下代码中发生这种情况。
def auth(request):
# start the OAuth process, set up a handler with our details
oauth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET, CALLBACK)
# direct the user to the authentication url
# if user is logged-in and authorized then transparently goto the callback URL
try:
auth_url = oauth.get_authorization_url()
except tweepy.TweepError:
return HttpResponse('error', status=500)
# store the request token
request.session['unauthed_token_tw'] = (oauth.request_token.key, oauth.request_token.secret)
return HttpResponseRedirect(auth_url)
我是 Python 和 Django 的新手,这个错误是否意味着 oauth.request_token 为空?我的回调网址可能有问题吗?我需要转发8000端口吗?任何帮助或指点将不胜感激!
【问题讨论】:
标签: python django oauth tweepy