errors when trying to tweet using tweepy
Asked Answered
L

1

7

I am working on an academic research project and I am trying to send out tweets using the the Twitter API. The error I am receiving repeatedly is

Forbidden: 403 Forbidden
Your client app is not configured with the appropriate oauth1 app permissions for this endpoint.
import tweepy

#from tweepy import OAuthHandler

ACCESS_KEY = 'xxx'
ACCESS_SECRET = 'xxx'
CONSUMER_KEY = 'xxx'
CONSUMER_SECRET = 'xxx'


api = tweepy.Client(bearer_token='xxx',
                    access_token=ACCESS_KEY,
                    access_token_secret=ACCESS_SECRET,
                    consumer_key=CONSUMER_KEY,
                    consumer_secret=CONSUMER_SECRET)


api.create_tweet(text='I want to Tweet')

Here is my code. The authentication raises no errors. Just the attempt at tweeting.

Livesay answered 14/11, 2022 at 18:49 Comment(0)
M
28

You can fix the problem by activating Read / Write in the Oauth section of your application, and then you shall regenerate the "Access Token and Secret".

You can check that are properly recreated when you see:

Created with Read and Write permissions

EDIT as of 10/February/2023: You are now required to ask for Elevated access if you want to have read + write permission. You only have read access from the V2 API Endpoints as of today

Multifarious answered 18/11, 2022 at 22:18 Comment(9)
How do you ask for elevated access?Nonce
nvm, I found it under settings > User authentication settingsNonce
I had activated the Read / Write but did not regenerate the tokens which left me confused for some time, but your post helped me, thank you!Estonian
thanks for adding to regenerate the tokens. fixed my problem :)Eldoraeldorado
after i regenerated the access tokens, i started getting Unauthorized, any idea what happened?Wail
Hi @bobmason, we lack some information about the issue, but I would guess you are still using the old token in the code instead of the new one you regeneratedMultifarious
@EnricFontSegarra Thank you, i have resolved it, since the whole thing was confusing when regenerating new keys, some old data was still in the app, never mind it's how they like to complicate things.Wail
as of 210524 : face this issue. fix it by regenerate "Access Token and Secret" . (didn't ask for elevated access). App permission is read and write.Bootery
Regenerate the Access Token solved my problem! That's it!Silicle

© 2022 - 2025 — McMap. All rights reserved.