I am trying to create a simple program that will allow me to get all the twits where a specific user is mentioned. When executing the code I received the error response: 401 Unauthorized
The project permissions are set to read/write and DM, additionally I have regenerated the API keys.
If someone can tell me where else can be the problem I would be very grateful.
Anyway I am going to attach the code to verify that it is not a problem of a function call.
This is what I have so far:
access_token = "XXXXXXX" # Access Token
access_token_secret = "XXXXXXX" # Access Token Secret
consumer_key = "XXXXXXX" # API Key
consumer_secret = "XXXXXXX" # API Key Secret
client = tweepy.Client(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token=access_token,
access_token_secret=access_token_secret
)
# Autenticación con la API de Twitter y creación del objeto API
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
max_tweets = 50
query = 'Iberia'
searched_tweets = client.search_all_tweets(query=query, max_results=max_tweets)
print(searched_tweets)