Search code examples
pythontwittertweepytwitter-oauth

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.

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

  • What fixed it was...

    When I used to have Essential access and generated the access token and secret, it was in "read-only". And even after getting elevated access and regenerating, it kept generating tokens still in "read-only".

    So I just set it as "read and write" and now it works fine. That's what fixed it. Such a small thing.