skip to Main Content

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


  1. 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:

    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: note that creating a tweet with duplicate content will result with tweepy.errors.Forbidden: 403 Forbidden

    Login or Signup to reply.
  2. this code works for me (all 5 keys are require for authentification) :

    import tweepy
    
    client = tweepy.Client(bearer_token=BEARER, consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET, access_token=ACCESS_KEY, access_token_secret=ACCESS_SECRET)
    
    client.create_tweet(text="Yeah boy! I did it")
    

    Source : https://stackoverflow.com/a/70062360/2267379

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search