tags:

views:

1093

answers:

2

Hi all

I'm trying to implement "twitter oauth" in appengine(python) using http://code.google.com/p/oauth-python-twitter.

I use the following code to redirect the user into 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)

the user is successfully redirected but when he returns in my application i receive the following error: HTTP Error 401: Unauthorized

  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)

the error occurate when i try to get an access token.

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.

Any idea? Thank you!

A: 

Make sure the user (or your self) has entered your app name in the Twitter authenticated section of their/your Twitter account so that your application has permission to connect.

alexy13
+2  A: 

i solved the problem just using the trunk version of oauth-python-twitter and python-twitter.

surfeurX

related questions