Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Twitter bot, Tweepy 4.10.1 gives Traceback error and tweepy.errors.Forbidden 403

I made sure that all the keys and secrets are correct, but I’m just not sure that I’m getting it.

(I HAVE ELEVATED ACCESS)
enter image description here

I was following this tutorial on YouTube.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is the Python code:

import tweepy

api_key = "XXXXX"
api_secret = "XXXXX"
bearer_token = r"XXXXX"
access_token = "XXXXX"
access_token_secret = "XXXXX"

# "XXXX" is just a placeholder, for when i post to Stack Overflow

client = tweepy.Client(bearer_token, api_key, api_secret, access_token, access_token_secret)

auth = tweepy.OAuth1UserHandler(api_key, api_secret, access_token, access_token_secret)
api = tweepy.API(auth)


client.create_tweet(text="Hello Twitter")

And this is the terminal error:
Error

>Solution :

From https://docs.tweepy.org/en/latest/faq.html#why-am-i-encountering-a-403-forbidden-error-with-api:

If you have Essential access to the Twitter API, you won’t be able to access Twitter API v1.1. This includes all API methods and Stream.

You can use Twitter API v2 with Client or apply for Elevated access.

See the Twitter API access levels and versions documentation for more information.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading