Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

errors when trying to tweet using tweepy

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.

like image 755
Evan Avatar asked Jun 04 '26 07:06

Evan


1 Answers

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

like image 182
Enriccus Avatar answered Jun 07 '26 22:06

Enriccus