0

I am using the Twitter API and I have a project that needs to collect tweets about COVID-19 on a specific date.

I get this error message during collection:

"error":{
  "message":"Forbidden: Authentication succeeded but account is not authorized to access this resource.",
  "sent":"xxxxxxxx",
  "transactionId":"xxxxxxxxxxxxxx"
}}',) 
(403): {"error":{"message":"Forbidden: Authentication succeeded but account is not authorized to access this resource.

I have a free 30-day sandbox so I did not pay for the premium because I am guessing there is no need? And I used it with the TwitterAPI library.

Here is the full code.

My Dev environment label: Sandbox

from TwitterAPI import TwitterAPI
from tqdm import tqdm
consumer_key = "xxxxx"
consumer_secret = "xxxxx"
access_token = "xxxxxxxxxxxxxx"
access_token_secret = "xxxxxx"
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = TwitterAPI(consumer_key, consumer_secret, access_token, access_token_secret)
r = api.request('tweets/search/30day/:Sandbox',
                {'query':'covid'}) 
tweets_copy = []
for tweet in tqdm(r):
    tweets_copy.append(tweet)
print(f"new tweets retrieved: {len(tweets_copy)}")

please I need your help I will appreciate any advice

Do you think if I upgrade to premium it will solve the problem?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
rafal Az
  • 11
  • 1
  • The message is very specific. I'm sure the API has documentation on it, but I would surmise that upgrading to a paid plan will fix your issue given that is says you authenticated but don't have access to a specific resource – ViaTech Jan 25 '21 at 22:05
  • "*guessing there is no need [to upgrade to the premium API] ?*" Can you elaborate on how you reached this "guess"/conclusion? The [documentation for the endpoint in question](https://developer.twitter.com/en/docs/twitter-api/premium/search-api/overview) pretty clearly indicates this endpoint is "Premium". – esqew Jan 25 '21 at 22:07
  • Have you not tried using bs4 to retrieve tweets? doesn't require the Twitter API – Insula Jan 25 '21 at 22:07
  • @esqew It said that free sandbox provides access to the premium APIs, but without some additional features – rafal Az Jan 27 '21 at 09:57

0 Answers0