I am trying to use Tweepy to create a bot that, when mentioned, will reply with some text, but I'm getting 403 errors. The errors state that I need to use keys and tokens connected to a Twitter developer project. I have these (my account is subscribed to Basic Access), but as far as I can see, the Tweepy docs don't make mention of where to put them?
I assume I'm just missing something obvious.
My code is:
import tweepy
TwitterAPIKey = "INSERT TOKEN HERE"
TwitterAPISecretKey = "MY REAL TOKENS"
TwitterBearerToken = "THESE ARE FILLER TOKENS, BUT MY ACTUAL CODE USES THE REAL ONES"
AccessToken = "I PROMISE THE ISSUE ISN'T THAT I'M USING PLACEHOLDER STRINGS LIKE THESE AS MY TOKENS"
AccessTokenSecret = "PLACEHOLDER TOKEN"
streaming_client = tweepy.StreamingClient(TwitterBearerToken)
streaming_client.add_rules(tweepy.StreamRule("@TwitterBotName"))
streaming_client.filter()
Running this code results in the following error:
Forbidden: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys
and tokens from a Twitter developer App that is attached to a Project.
You can create a project via the developer portal.