I have the following function:
import tweepy
def tweet_message(text):
# Replace these with your own API key and secret
api_key = API_KEY
api_secret = API_KEY_SECRET
access_token = ACCESS_TOKEN
access_token_secret = ACCESS_TOKEN_SECRET
# Authenticate with Twitter API
auth = OAuthHandler(access_token, access_token_secret)
api = tweepy.API(auth)
# Tweet the text
api.update_status(status=text)
I am using Tweepy to post tweets via Python.
I have elevated access developer account and I have all of the following keys:
API_KEY = '...'
API_KEY_SECRET = '...'
BEARER_TOKEN = '...'
CLIENT_ID = '...'
CLIENT_SECRET = '...'
ACCESS_TOKEN = '...'
ACCESS_TOKEN_SECRET = '...'
But when I run the function, I get this error:
TweepError: [{'code': 220, 'message': 'Your credentials do not allow access to this resource.'}]
Where am I going wrong? My credentials should allow access to it.
It seems like you are using api keys to authenticate but you should be using user access tokens.
statuses/update
is an API that you (as the app owner) call on behalf of the user. To be able to do this, you need to authenticate the user and call the API using the access tokens that you got from Twitter for that user.