1

Here is my code:- I have double checked all the auth parameters.

import tweepy


CONSUMER_KEY ='#Omitted - you should not publish your actual key'
CONSUMER_SECRET ='#Omitted - you should not publish your actual secret'
ACCESS_KEY='#Omitted - you should not publish your access key'
ACCESS_SECRET = '#Omitted - you should not publish your access secret'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

api.update_status('Tweeting from command line')

Saved the file in home folder as status.py after running python status.py follwing error comes:-

Traceback (most recent call last):
  File "status.py", line 14, in <module>
    api.update_status('Tweeting from command line')
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/binder.py", line 185, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/binder.py", line 168, in execute
    raise TweepError(error_msg, resp)
tweepy.error.TweepError: Could not authenticate with OAuth.

Please, help me out

3 Answers 3

3

I received this error under the same conditions - using tweepy, all of my keys/secrete were copy and pasted correctly. The problem was the time on my server. After running ntpdate -b pool.ntp.org I was to use tweepy just fine.

Sign up to request clarification or add additional context in comments.

Comments

0

I am able to authenticate using tweepy, I have an extra line in my code though, it might help for you to change your code to this:

import tweepy
from tweepy import OAuthHandler

then proceede with the rest of your code. Also add a line in your code to print out to the shell to show your connect as follows:

print api.me().name

Make sure the line you see above this is right after api = tweepy.API(auth)

8 Comments

i added the line u said... here is what code looks like now:- import tweepy from tweepy import OAuthHandler CONSUMER_KEY ='#' CONSUMER_SECRET ='#' ACCESS_KEY='#' ACCESS_SECRET = '#' auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) print api.me().name api.update_status('Tweeting from command line')
here is the error:- Traceback (most recent call last): File "newstatus.py", line 13, in <module> print api.me().name File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/api.py", line 182, in me return self.get_user(screen_name=self.auth.get_username()) File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/auth.py", line 161, in get_username raise TweepError("Unable to get username, invalid oauth token!") tweepy.error.TweepError: Unable to get username, invalid oauth token!
looks like Tweepy is having a difficult time getting your oAuth token, check up at dev.twitter.com login and make sure everything is exactly correct. Just copy and paste the code in. Also in future its ok to make edits to your original question, this way there is no character limit when making a response.
i have double checked the keys and secrets... Can u suggest if there are any other possible causes of this error??
The command api.status_update('Tweeting from the command line') I'm thinking might be the error, it looks like in your error message that might be causing an error. Also you might want to try and reset your OAuth token as it is saying its invalid. Other than that I'm sorry I do not know. But lets see what that does and see if we can dope it out.
|
0

Try api.update_status(status='Tweeting from command line'). It helped me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.