I purchased Elevated access specifically in order to use the full archive search endpoint, but I am not able to authenticate properly. I get the error

tweepy.errors.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.

The keys and tokens that I am using are apps attached to my project. I want to use App-only authentication because I don’t need to do anything except search for tweets, no actions on behalf of users. I have tried the following code with both the bearer tokens for multiple apps attached to my project and the bearer tokens that are generated via curl at the oauth2/token endpoint.

All of those bearer tokens yield the same error. The apps are attached to a project that has Elevated access and shows v1 and v2 API access. Please let me know if anyone has experienced this!

client = tweepy.Client(bearer_token=bearer_token)

tweets = client.search_all_tweets(query=query, tweet_fields=['context_annotations', 'created_at'],
                              start_time=min_date,
                              end_time=max_date, max_results=100)

What exactly did you buy?

1 Like

I have the exact same issue. I have created a new app in my Elevated Access project, regenerated the bearer token N number of times, and I’m using it exactly within the OP’s scopes (just searching), but I continue to get this error:

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.

The thing is, I have done this. I’ve deleted my apps a few times and created new ones under the same project but no luck. How do I fix this?

Which endpoint are you using?
The archive endpoints are not available with elevated access. They are only with academic access

1 Like

Oh wait, this calls the Academic Access API, a v2 API that is only available for research Twitter Developer Access - twarc

You may have bought v1.1 Premium Search API which is an entirely different API. You can still use tweepy to make calls to this API but I would suggest familiarizing more with it because it’s extremely restricted and limited in the number of calls you make, so it’s easy to waste your entire monthly call limit running one command.

I would recommend trying calls in the 30day endpoint to practice and make sure you know what data you want, and then run the paid queries. Premium search APIs | Docs | Twitter Developer Platform

Hi all, thanks very much for these comments. I confess I am still confused about exactly what the access I have entails, but I was able to do a full-archive search with the v1.1 Premium Search API and the following code:

auth = tweepy.OAuth2BearerHandler(bearer_token=bearer_token)
api = tweepy.API(auth)
tweets=tweepy.Cursor(api.search_full_archive,environment_name=api_environment_name, query=query, fromDate=min_date).items(max_results)
1 Like