Bani
Bani

Reputation: 111

Twitter API V2 403: Forbidden using tweepy

I'm not able to authenticate using my twitter developer account even though my account active

import tweepy
consumer_key= 'XX1'
consumer_secret= 'XX2'
access_token= 'XX3'
access_token_secret= 'XX4'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
api.update_status("Hello Tweepy")

i'm getting error :

Forbidden: 403 Forbidden

453 - You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve

There is no option to move to Essential to Elevated on the developer portal. any suggestion ?

Upvotes: 4

Views: 25641

Answers (4)

Antti Rytsölä
Antti Rytsölä

Reputation: 1543

My problem was that I had created the tokens prior to setting the app to read/write mode. The tokens use the prior setting, so the tokens need to recreated after changing to read/write mode.

from here: https://twittercommunity.com/t/forbidden-to-use-retweet-v2/159706

Upvotes: 1

AngryCoder
AngryCoder

Reputation: 496

There is no need to "Elevate" your access unless your app has these specific requirements: enter image description here

Where the "Essential" (the one that you have by default) access has the following ones: enter image description here

In the case that the OP is referring, he is trying to send a tweet, so the code for using Tweepy + Twitter API v2 will be something like this:

import tweepy
client = tweepy.Client(consumer_key="",
                    consumer_secret="",
                    access_token="",
                    access_token_secret="")
# Replace the text with whatever you want to Tweet about
response = client.create_tweet(text='hello world')

Remember that your access_token + access_token_secret will have to be generated with Read&Write permissions in order to be able to send tweets (Otherwise you will get a 403 error with previous code): enter image description here

See https://twittercommunity.com/t/how-do-i-change-my-app-from-read-only-to-read-write/163624/4 for more details on how to do it.

Upvotes: 6

Bani
Bani

Reputation: 111

I found out that Essential access can use only Twitter API v2

The code should be

import tweepy
consumer_key= 'x'
consumer_secret= 'xx'
access_token= 'xxx'
access_token_secret= 'xxxx'

client = tweepy.Client(consumer_key= consumer_key,consumer_secret= consumer_secret,access_token= access_token,access_token_secret= access_token_secret)
query = 'news'
tweets = client.search_recent_tweets(query=query, max_results=10)
for tweet in tweets.data:
    print(tweet.text)

Thanks to https://twittercommunity.com/t/403-forbidden-using-tweepy/162435/2

Upvotes: 5

Anurag
Anurag

Reputation: 318

There are options in the dashboard. You have to submit an application for access.

Refer image:

Dashboard

Upvotes: 3

Related Questions