In project overview it says elevated and the project has v1.1 and v2 access, in the project OAuth1 and OAuth 2 are turned on, The app permissions are read and write.

using this code

import tweepy as tw
auth = tw.OAuthHandler(keys.consumer_key, keys.consumer_secret_key)
api = tw.API(auth, wait_on_rate_limit=True)
tweet = api.update_status(“Testing tweepy API v1”)

using the consumer keys I get error
tweepy.errors.Forbidden: 403 Forbidden
220 - Your credentials do not allow access to this resource.

using the access keys
tweepy.errors.Unauthorized: 401 Unauthorized
32 - Could not authenticate you.

I’m already using all these keys with some v2 code and that’s working fine.

I’m not sure which keys I should be using or what the problem can be.

Have you set your permission to write? Post tweet requires write access permission and must be set in developer dashboard, once modified you need to regenerate key.

1 Like

the access token and secret says

Generated January 9, 2022
Created with [Read and Write] permissions

I regenerated they key just in case but I still get

tweepy.errors.Unauthorized: 401 Unauthorized
32 - Could not authenticate you.

Went back to basics and investigated the code as everything else sounds right.
Turns out I was just doing it wrong.
this works

auth = tweepy.OAuth1UserHandler(
   consumer_key, consumer_secret, access_token, access_token_secret
)

api = tweepy.API(auth)
image=".\dataframe.png"
media=api.media_upload(image)

try:
     api.update_status("Test",media_ids=[media.media_id])
except Exception as e:
     print(e.__class__)
     print(f"Exception occured - {e}")
else:
     print("Success")
2 Likes

so the point of error is here?

Thanks for clarifying, It will be useful for other developers

1 Like

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