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 "…tweepyapi.py", line 46, in wrapper
return method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^ File "C:…tweepyapi.py", line 979, in update_status
return self.request(
^^^^^^^^^^^^^ File "C:…tweepyapi.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
2
Answers
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:
Edit: note that creating a tweet with duplicate content will result with
tweepy.errors.Forbidden: 403 Forbidden
this code works for me (all 5 keys are require for authentification) :
Source : https://stackoverflow.com/a/70062360/2267379