0
從請求交換有麻煩的OAuth訪問令牌和祕密憑證任何幫助將是巨大的一切似乎是在正確的地方Tweepy「沒有ACCESS_TOKEN採集數據」
TweepError: HTTP Error 401: Unauthorized
callback_url = urllib.quote("%s?twitterCallback=1" % self.request.url)
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)#, callback_url
try:
redirect_url = auth.get_authorization_url()
except tweepy.TweepError:
print 'Error! Failed to get request token.'
request_token = [auth.request_token.key, auth.request_token.secret]
tmpldict['twitauthurl'] = redirect_url
oauth_verifier = self.request.values.get('oauth_verifier',None)
oauth_token = self.request.values.get('oauth_token',None)
if oauth_verifier:
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_request_token(request_token[0], request_token[1])
access_token = {}
try:
access_token = auth.get_access_token(oauth_verifier)
except tweepy.TweepError:
print 'Error! Failed to get access token.'