Getting UNAUTHORIZED_ACCESS while trying to use Ads API even after approval



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


ACCOUNT_ID = 'xxx'


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!


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.


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?


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


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.



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?


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