Hey @carmenjyuen, I hope you are doing well.
I saw similar questions on this, but they are closed, the reason why I decided to open this one.
So basically I am trying to access the analytics apis but I am getting this error :
{
“errors”: [
{
“code”: “UNAUTHORIZED_ACCESS”,
“message”: “This request is not properly authenticated”
}
],
“request”: {
“params”: {}
}
}```
I am using postam or python to make the request and I am getting the same error still.
Here is how I am making the request with postman. :


Neither postman , nor python code which is here is returning a successful response.
import requests
import os
import sys
from tweepy import OAuthHandler
from dotenv import load_dotenv
load_dotenv()
def get_twitter_auth():
"""Setup Twitter authentication.
Return: tweepy.OAuthHandler object
"""
try:
consumer_key = os.getenv('TWITTER_CONSUMER_KEY')
consumer_secret = os.getenv('TWITTER_CONSUMER_SECRET')
access_token = os.getenv('TWITTER_ACCESS_TOKEN')
access_secret = os.getenv('TWITTER_ACCESS_SECRET')
assert all([consumer_key, access_secret, access_token, consumer_secret])
except KeyError:
sys.stderr.write("TWITTER_* not found\n")
sys.exit(1)
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
return auth.apply_auth()
protected_url = "the url"
oauth = get_twitter_auth()
response = requests.get(url=protected_url, auth=oauth)
print(response.content, 10 * "**=|")
FYI :
My application id is : 21264692
When I do :
twurl -t -H ads-api.twitter.com "/8/accounts" I am getting the following response which seems to be a success one:
{"request":{"params":{}},"next_cursor":null,"data":[{"name":"Spiny Trends \uD83E\uDD94","business_name":null,"timezone":"America/Los_Angeles","timezone_switch_at":null,"country_code":null,"id":"18ce5580mcx","created_at":"2020-08-05T06:25:21Z","updated_at":"2020-08-05T06:25:21Z","industry_type":null,"business_id":null,"approval_status":"ACCEPTED","deleted":false}]}
Is there anything I am missing?
Thank you in advance for your time.
EDIT: UPDATE , it seems to work with twurl