I'm trying to authenticate to twitter's new API (v2) using tweepy and retrieve tweets but encounter a strange error related to the authentication process.
I'm currently using the free access to the API.
Code sample :
import tweepy
# Authentification OAuth 1.0a User Context to retrieve my own data
dict_twitter_api = {
"consumer_key": "blah",
"consumer_secret": "blah",
"access_token": "blah",
"access_token_secret": "blah"
}
client = tweepy.Client(**dict_twitter_api)
# If you're working behind a corporate proxy,
# client.session.proxies = {
# "http": "my-corporate-proxy",
# "https": "my-corporate-proxy",
# }
print(client.get_me()) # <-- this works well
print(client.get_home_timeline())
Traceback result :
> 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.
I've checked my different tokens and confirmed that the OAuth 1.0a user context authentication should be working to retrieve my own timeline.