Hello,

New to the Twitter Developer. I am following this [tutorial] but running into authorization error.

I have pasted the code below and the response I am getting back.
Any help would be appreciated.

api.update_status("Test tweet from Tweepy Python")

The response is this:

> ---------------------------------------------------------------------------
TweepError                                Traceback (most recent call last)
<ipython-input-8-ec7f5b2c264d> in <module>
----> 1 api.update_status("Test tweet from Tweepy Python")

~/opt/anaconda3/lib/python3.8/site-packages/tweepy/api.py in update_status(self, *args, **kwargs)
    203             kwargs['media_ids'] = list_to_csv(kwargs['media_ids'])
    204 
--> 205         return bind_api(
    206             api=self,
    207             path='/statuses/update.json',

~/opt/anaconda3/lib/python3.8/site-packages/tweepy/binder.py in _call(*args, **kwargs)
    251                 return method
    252             else:
--> 253                 return method.execute()
    254         finally:
    255             method.session.close()

~/opt/anaconda3/lib/python3.8/site-packages/tweepy/binder.py in execute(self)
    232                     raise RateLimitError(error_msg, resp)
    233                 else:
--> 234                     raise TweepError(error_msg, resp, api_code=api_error_code)
    235 
    236             # Parse the response payload

TweepError: [{'code': 32, 'message': 'Could not authenticate you.'}]

Hi and welcome to the Twitter Developer Platform :wave:

Error 32 usually means the request received some authentication data, but they are not valid. It’s possible that the authentication values are incomplete or invalid (this can happen for example when you accidentally send your access token secret in the field for the access token).

I couldn’t see the link to the tutorial you’re following; can you please try and paste the link again? We can give you more detailed guidance if we follow what you follow.

Thank You Daniele for the welcome and the response.

It is possible that I am pasting the tokens in the wrong places. But a step earlier I did verify my credentials.

I tried adding the link yesterday but the forum wouldn’t let.
The tutorial is called How to Make a Twitter Bot in Python With Tweepy and it is written by Miguel Garcia.

Thanks,

Hi again! I tried out the instructions from the tutorial. It’s more than likely that the credentials are passed in the wrong order.

Locate the line where tweepy.OAuthHandler is called. The first value should be the API Key, the second value should be the API Secret key. You should have found these details from your developer portal under your Keys and tokens.

Screen Shot 2021-05-07 at 3.59.23 PM

auth = tweepy.OAuthHandler("your API key", "your API secret key")

# add the rest of your code here, including auth.set_access_token

Make sure to remove any extra spaces at the beginning or at the end of both values. If you still have issues with these credentials, you can try and generate new values. To do so:

  1. Head over to your developer portal.
  2. Select the app you’re using for this tutorial
  3. Select Keys and Tokens
  4. Select Regenerate
  5. Follow the instructions

Hope this helps. Let us know how it goes!

2 Likes

Dear Daniele,

Thank You for your thorough response. Well appreciated.
Your suggestion worked and I am good to go!!

Best Regards,

Yasser

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.