Using the below python code, while the authentication is successful, I get the following error:
Error Code: 453: You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
I am currently using the free version on developer.twitter.com.
Code:
import tweepy
# Authenticate to Twitter
auth = tweepy.OAuthHandler("CONSUMER_KEY", "CONSUMER_SECRET")
auth.set_access_token("ACCESS_TOKEN", "ACCESS_TOKEN_SECRET")
# Create API object
api = tweepy.API(auth)
try:
api.verify_credentials()
print("Authentication OK")
except:
print("Error during authentication")
# Create a tweet
api.update_status("content of tweet")
In this link, the right access is described as follows:
Free
- For write-only use cases and testing the Twitter API
- Rate limited access to v2 tweet posting and media upload endpoints
- 1,500 Tweets per month - posting limit at the app level
- 1 app ID
- Login with Twitter
And this is error log:
Authentication OK
Traceback (most recent call last): File "...\create_tweet.py", line 19, in api.update_status('content of tweet') File "...\tweepy\api.py", line 46, in wrapper
return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:...\tweepy\api.py", line 979, in update_status return self.request( ^^^^^^^^^^^^^ File "C:...\tweepy\api.py", line 271, in request
raise Forbidden(resp) tweepy.errors.Forbidden: 403 Forbidden 453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
As mentioned in the comments under your question, it is possible to post tweets using V2 endpoints. These endpoints are supported by tweepy, and a working code sample would be as follows:
import tweepy
client = tweepy.Client(
consumer_key=API_KEY,
consumer_secret=API_KEY_SECRET,
access_token=ACCESS_TOKEN,
access_token_secret=ACCESS_TOKEN_SECRET
)
client.create_tweet(text='Test.')
Edit 1: note that creating a tweet with duplicate content will result with tweepy.errors.Forbidden: 403 Forbidden.
Edit 2: Place yourself in tab Free on https://developer.twitter.com/en/portal/products, and make sure that your project is listed there. Your app has to be under the project, i.e. it can't be standalone app anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With