UNAUTHORIZED_ACCESS This request is not properly authenticated


#1

Hi, I am new here. I have a problem when accessing the ads-api.
My owner_id is 17284224
I never succeeded in accessing the ads-api, and it always the same error as below.
But I did authorized it with or without using Oauth by following the tutorial on twurl.

I am wondering if I am using the wrong ID. since the IDs I see from the similar posts are very different from mine. So another question is where to find the ads account id? Is owner_id the ads account id?

I already finished the following two commands successfully

twurl authorize --consumer-key key --consumer-secret secret
twurl authorize -u username -p password  --consumer-key key  --consumer-secret secret

And it returns my owner name and owner id along with my api key by executing commands

twurl accounts

But it returns the errors when querying the data as below

twurl -H ads-api.twitter.com "/0/accounts"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1/accounts"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}%

Could anybody help me here? Thanks


#2

Hi @jingli430!

Regarding your ID, it looks like you’re using the base-10 version of your ID vs the base-36 in which you’re supposed to use in the twurl calls. Here is an online converter to get your base-36 ID. Note that your base-36 should be in all lower case. Another way to find the correct account ID is to log into the account on ads.twitter.com then pull it out the URL. Can you try using the twurl command again with correct account ID (base-36) to the v1 endpoint and let me know what it returns?


#3

Hi @goforbrent, thanks so much for the reply.
I generate the base36 ID AAGLC based on my base10 ID 17284224 using your link.
And it should be all lowercase like aaglc

And just like you said, I did also see the ID in the URL

since the twurl didn’t use the ID information to create the authorization, and it authorized successfully. I queried the v1 endpoint again as follows

twurl -H ads-api.twitter.com "/0/accounts"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1/accounts"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1/accounts/aaglc"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1.1/accounts/aaglc"
{"errors":[{"code":215,"message":"Bad Authentication data."}]}%

BTW, I see many peoples get different format ID
18ce548hnmt for example in the following post. Unauthorized_access

I am curious to know what kind of ID they are using there? Are they using different base?

Thanks
Jing


#4

Could anyone help me here?

Thanks


#5

Hi

When you authorizes in twurl, do you access to a website with a login in twitter, and you get a pin that you introduce in your command line? If the answer is NO, you’re not doing it well.

Thanks


#6

Hi Hector, thanks for the reply.

(1) when I execute the twurl authorization commands, it did give me a url

twurl authorize --consumer-key key --consumer-secret secret
twurl authorize -u username -p password  --consumer-key key  --consumer-secret secret

(2) I click the url, it brings me to a webisite, I click on “authorize”, then it gives a pin


(3) I copy and paste the pin back to my command line, then it shows authorization successfully.

So I think I am following the instruction from twurl tutorial correctly to get my authorization.
And I can execute command twurl accounts to confirm it.

And then I still get the same error when querying the endpoints as I did in the previous reply.

Please be free to let me know what I missed here.

Best


#7

Mmmmm,

It’s a little bit strange, the process looks perfect for me, but I can see, in my opinion, too much accounts when you execute ‘twurl accounts’

Could you please go to your home directorey an delete te file “.twurlrc”? It manages all the connections and different apikey.

After that could you do the authorization process again?

Thanks!


#8

thanks, it only show one record now.

now, it popped up a different message as below, does it mean my app need to be authorized first before the user gets authorized?

twurl -H ads-api.twitter.com "/1/accounts"
{"errors":[{"code":"UNAUTHORIZED_CLIENT_APPLICATION","message":"The client application making this request does not have access to this API"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1/accounts/aaglc"
{"errors":[{"code":"UNAUTHORIZED_CLIENT_APPLICATION","message":"The client application making this request does not have access to this API"}],"request":{"params":{}}}%

twurl -H ads-api.twitter.com "/1/accounts/17284224"
{"errors":[{"code":"UNAUTHORIZED_CLIENT_APPLICATION","message":"The client application making this request does not have access to this API"}],"request":{"params":{}}}%

#9

First of all, it looks like you have saved bad credentials, so you were always using the same bad credentials always, because if you authorize again, you should select the correct account.

In the other hand, yes you APP should be whitelisted by the Twitter Ads API Team.


#10

but if it is a bad credential, it should not be successfully authorized, right?

any suggestion? modify my password? re-generate the customer key and secret? and re-authorize after?


#11

Sorry, i was talking about why you have before the problems. If you regenerate tokens you lose your previous credentials, that could be one reason why you had problems before.

But forget that, now, your problem is other. Your app should be whitelisted by the Twitter Ads API team in order to get access. Maybe @carmenjyuen could help you.

Thanks


#12

Thanks so much Hector!


#13

Hi @hector_borras @carmenjyuen,
Hope you had a great vacation. I still have the same issue when I retried, I still need help in but please do not do it while you are off.

Thanks
Jing


#14

Hi @jingli430 (thanks @hector_borras for the mention!),

Can you let me know what your application ID is? You can find this in the URL of your application at app.twitter.com.

I’ll check your access ASAP. I don’t believe I found an application with Smule, so if you didn’t already apply, please fill out the form here: https://dev.twitter.com/ads/ads-api-access-developer.

Best,
Carmen


#15

Hi Carmen, thanks for the reply here!
I will fill out the form with our business team tomorrow asap and keep you posted.

Owner ID 17284224
App ID: 8252575


#16

Thanks @jingli430! I just approved your access - you now have 5 OAuth tokens to work with. Let me know if you have any questions.

Best,
Carmen


#17

Thank you very much @carmenjyuen!


#18

How do I resolve this
An Api instance must be provided as argument or set as instance in the \TwitterAds\Api


#19

Hi @opassky,

Which library are you using?

This one?

Could you paste also some lines of your code?

Thanks