I’ve been trying (and failing) for the life of me to just simply connect to the twitter api using tweepy and post 1 tweet. I have no idea why my code won’t work, it keeps giving me the error that I don’t have a high enough access level. (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.)
import tweepy
from credentials import twitter_bot_keys
auth = tweepy.OAuth1UserHandler(
twitter_bot_keys['API Key'],
twitter_bot_keys['API Key Secret'],
twitter_bot_keys['Access Token'],
twitter_bot_keys['Access Token Secret']
)
api = tweepy.API(auth)
api.update_status("test")
(Obviously the credentials.py file has my actual credentials in their respective areas)
Any help would be greatly appreciated.
Tried everything, expected it to post a tweet. Also expected it not to be such a nightmare to use this awful API
2
Answers
Used the working code sample from Viktor Brešan in Twitter API access denied for posting a simple tweet
No idea why that worked instead, but it did so I used that as a base.
Tweepy contributor here,
Tweepy.org does support both new v2 and v1.1 APIs
It looks like you are trying to pass Twitter/X’s v2 API credentials instead of v1.1, you can either create new v1.1 credentials from X developer portal or you can use v2 credentials like this
Refer to https://docs.tweepy.org/en/stable/examples.html#examples