2 years ago

#54126

test-img

user3062448

I receive authentication issues when using Twitter API

I have tried to authenticate Twitter API several times in different ways and I keep getting an authentication error. I have tried requesting the latest elevated version as well but I cannot get it to work.

This is my code:

import tweepy

 # Variables that contains the credentials to access 
 Twitter API
ACCESS_TOKEN = 
ACCESS_SECRET = 
CONSUMER_KEY = 
CONSUMER_SECRET = 

# Setup access to API
def connect_to_twitter_OAuth():
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)

    api = tweepy.API(auth)
    return api


# Create API object
api = connect_to_twitter_OAuth()
# tweets from my stream
public_tweets = api.home_timeline()
for tweet in public_tweets:
    print(tweet.text)

This is the result:

TweepError: [{'message': 'You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve', 'code': 453}]

I have tried the following tutorials but I cannot get the authentication to work. The tutorials did not mention elevated access and I'm not sure if there is a way to do this without:

https://gist.github.com/alexdeloy/fdb36ad251f70855d5d6

https://www.pythoncentral.io/introduction-to-tweepy-twitter-for-python/

https://towardsdatascience.com/my-first-twitter-app-1115a327349e

https://towardsdatascience.com/tweepy-for-beginners-24baf21f2c25

I have also looked at other stack overflow questions and answers and nothing seems to work.

I just want to get tweets from a specific user.

python

twitter

tweepy

twitter-oauth

twitterapi-python

0 Answers

Your Answer

Accepted video resources