'Twitter API v2 endpoints authentication error
I am trying to pull tweets using Twitter Developer API V2. My access level is Elevated. This is how my code looks like:
import tweepy
consumerKey = "*********mc7K"
consumerSecret = "*******BZNB"
accessToken = "*****-****9eeT"
accessTokenSecret = "****sWAa"
bearerToken="****VRqn"
client = tweepy.Client(wait_on_rate_limit=True, bearer_token=bearerToken, consumer_key=consumerKey, consumer_secret=consumerSecret, access_token=accessToken, access_token_secret=accessTokenSecret)
tweets = client.search_all_tweets(query=search_query, tweet_fields=['context_annotations', 'created_at'], max_results=10)
This throws me an error saying:
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.
But if I use tweets = client.search_recent_tweets(query=search_query, tweet_fields=['context_annotations', 'created_at'])
, it works fine.
What am I missing here?
Solution 1:[1]
Tweepy - TWITTER API V2 REFERENCE
Client.search_all_tweets
This endpoint is only available to those users who have been approved for the Academic Research product track.
The full-archive search endpoint returns the complete history of public Tweets matching a search query; since the first Tweet was created March 26, 2006. The Tweets returned by this endpoint count towards the Project-level Tweet cap.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |