3

I am fairly new to the Twitter API and I've got the following issue.

I try to send a tweet with the 'Twitter v2 API / Manage tweets / POST Create a Tweet' endpoint. Unfortunately this results in an error '429', every time I call this endpoint (manually)

{
    "title": "Too Many Requests",
    "detail": "Too Many Requests",
    "type": "about:blank",
    "status": 429
}

The returning header shows nothing strange (from my inexperienced point of view) , see screenshot below

Headers of 429 response

Some general remarks:

  • I've got just 1 application in my Twitter developer account.
  • Within this application there is just one App.
  • I am the only one who generates the requests manually.
  • The execution is manual and all within the boundaries of the API (200 per 15 min)

I started with the 'out the box' create_tweet.py solution (see link below), due to my misunderstanding I made several authorisation request with the same twitter user, (following the link, entering the PIN) maybe that triggered some type of blockage or rejection? I regenerated all my tokens and started all over via Postman (as mentioned in the Quickstart, see link below) The error 429 is still there (both with the python script as via Postman)

Anyone got an idea?

Links:

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ABBOV
  • 55
  • 4

1 Answers1

0

I'm not sure if this answers your question. Your Twitter API Keys might have read-only access as shown below.

enter image description here

and not read and write permissions as shown below.

enter image description here

You can set the read and write permissions this way:

  1. Go to the URL https://developer.twitter.com/en/portal/dashboard
  2. Select your project application
  3. Go to the "Settings" tab
  4. Select the "User authentication settings" section at the bottom
  5. Add the authentication for read and write
  6. Select "Native App" under Type of Apps
  7. Fill in the Callback URL and Website URL. I used junk for this
  8. Save these settings
  9. Go back to the "Keys and Tokens" tab on your application detail page.
  10. Locate the "Authentication Tokens" section
  11. Click "Add"/"Regenerate". This will generate a new token with "read and write" permissions.

I used the code below to post a new tweet to my Twitter account.

import tweepy


consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""

client = tweepy.Client(consumer_key, consumer_secret, access_token, access_token_secret)
try:
   client.create_tweet(text="This is an automated test")

except requests.exceptions.ReadTimeout:
     pass
except requests.exceptions.Timeout:
     pass
tweepy.errors.TweepyException as e:
     print(e)
     pass

Life is complex
  • 15,374
  • 5
  • 29
  • 58