Getting UNAUTHORIZED_ACCESS while trying to use Ads API even after approval

api

#1

Hi everyone.

I have been trying to build a Twitter Ads API solution using the python SDK but I am unable to load the advertiser account instance. This is the basic code.

from twitter_ads.client import Client
from twitter_ads.campaign import Campaign
from twitter_ads.enum import ENTITY_STATUS

CONSUMER_KEY = 'xxx'
CONSUMER_SECRET = 'xxx'
ACCESS_TOKEN = 'xxx'
ACCESS_TOKEN_SECRET = 'xxx'

ACCOUNT_ID = 'xxx'

client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

account = client.accounts(ACCOUNT_ID)

It works fine till the client is initialised.

But I get this error while initialising the account:

<NotAuthorized object at 0x103dd1730 code=401 details=[{u'message': u'This request is not properly authenticated', u'code': u'UNAUTHORIZED_ACCESS'}]>

Has my access to Twitter Ads API been revoked or is this some other issue? Any help is appreciated.

Thank you!


#2

Hi @abhishekkalia! When you don’t have access to the Ads API, you get the error

{"errors":[{"code":"UNAUTHORIZED_CLIENT_APPLICATION","message":"The client application making this request does not have access to this API"}],"request":{"params":{...}}}

The error you’re getting usually appears when the parameters are not encoded properly, and they mess up the Authorization header.


#3

Just to clarify,

The instance of the client is initialized but as soon as try to create an instance of the account, this error comes up.

Could this be an issue with SDK itself?


#4

Maybe. I don’t use the Python SDK so I can’t help here, unfortunately.


#5

Looks like the issue here is that your client_app_id hasn’t been whitelisted for Ads API access. Please re-try once the whitelist has been confirmed.

Thanks!


#6

I received an acceptance for the Ads API Development access. Do I need to apply to get whitelisted? What is the process for getting my client_app_id whitelisted?


#7

It has started to work now with the same code for some reason. Thanks for the help!