Hello everyone,
I want to use Twitter API for my project, but I have faced a problem, I cannot really solve.

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
public_tweets = api.home_timeline()
for tweet in public_tweets:
    print(tweet.text)

When I run this code I get something like: “401 Unauthorized 32 - Could not authenticate you”.
Please lend a hand to solve this problem, thanks in advance.

This is using the v1.1 API, not the v2 API - you may need to use tweepy.Client — Twitter API v2 Reference — tweepy 4.5.0 documentation if you only have “Essential” API access.

1 Like