Hi,

I would like to collect non public data & organic metrics of tweets.

I did it in Python.

from requests_oauthlib import OAuth1Session

oauth = OAuth1Session(api_key, client_secret=api_secret,
                      resource_owner_key=access_token,
                      resource_owner_secret=access_token_secret)

query = "tweets?ids=1576284681191837696&expansions=author_id&tweet.fields=created_at,non_public_metrics,public_metrics,organic_metrics&user.fields=username,verified"

url = f"https://api.twitter.com/2/{query}"
response = oauth.get(url)

Then I get the response :

{'resource_type': 'tweet',
   'field': 'non_public_metrics.impression_count',
   'parameter': 'ids',
   'resource_id': '1576284681191837696',
   'title': 'Field Authorization Error',
   'section': 'data',
   'detail': "Sorry, you are not authorized to access 'non_public_metrics.impression_count' on the Tweet with ids : [1576284681191837696].",
   'value': '1576284681191837696',
   'type': 'https://api.twitter.com/2/problems/not-authorized-for-field'},
  {'resource_type': 'tweet',
   'field': 'non_public_metrics.url_link_clicks',
   'parameter': 'ids',
   'resource_id': '1576284681191837696',
   'title': 'Field Authorization Error',
   'section': 'data',
   'detail': "Sorry, you are not authorized to access 'non_public_metrics.url_link_clicks' on the Tweet with ids : [1576284681191837696].",
   'value': '1576284681191837696',
   'type': 'https://api.twitter.com/2/problems/not-authorized-for-field'},...

Do you have any idea to solve the problem ?

Thanks

Is the access token you’re using, definitely belonging to @JuMottet (the tweet author) - it should begin with 202603895-

Hi @IgorBrigadir, this is my variable values :

api_key = "1xVl***"
api_secret = "t2z3W***"

access_token="784737366***"
access_token_secret = "qePgjc***"

My app is in production mode and I have a status elevated actived.

I could get recent tweets but it is impossible for me to get : non_public_data & organic_metrics of the tweets.

Does it help you to find the solution ?

This access token belongs to some other account, only an access token belonging to the tweet author can be used to retrieve private metrics

Oh… I thought I could have access to everyone’s tweets (not necessarily my user’s)