I am trying to write a twitter client application in python. I would like to use xAuth for authentication. My choice on the library is tweepy, because it seems that it knows everything I need.
Here is my problem:
>>> import tweepy
>>> auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
>>> auth.get_xauth_access_token('username', 'password')
Traceback (most recent call last):
File "<stdin开发者_如何转开发>", line 1, in <module>
File "tweepy/auth.py", line 152, in get_xauth_access_token
raise TweepError(e)
tweepy.error.TweepError: HTTP Error 401: Unauthorized
The username and the password is correct, I can log in with them. The CONSUMER_{KEY,SECRET} also valid, I copypasted them from the page of my application.
Do you have any idea why the code above fails?
Have you emailed Twitter support to get them to turn on xAuth for your application?
Twitter only want xAuth to be used by desktop and mobile applications, so registered applications have xAuth disabled by default, and you need someone at Twitter to turn it on for you. If you application doesn't have xAuth enabled, you get a 401.
To get xAuth enabled, send an email to api@twitter.com with the name of your application and the reason it needs xAuth instead of plain old OAuth (eg. it's not appropriate to pop up a web browser in my desktop application).
精彩评论