Pergunta

Having trouble getting the oauth access token and secret exchanged from the request tokens any help would be great everything else seems to be in the right place

 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.'
Foi útil?

Solução

Needed to store the request token data in the session and recall it in the second part. the call was creating a new request token.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top