authError Invalid Credentials in dfa-reporting-sample API v2.6

265 views
Skip to first unread message

Abhijit Bhosale

unread,
Oct 26, 2016, 1:10:10 PM10/26/16
to Google's DoubleClick Campaign Manager API Forum

Hi,

I have taken the following steps while using this DFA API but running into technical issue,

Step 1: Created a Project on Google console developer  as web application Client, where we get the Client Id and Client Secret.

Step 2: I have downloaded the Google API PHP Client Library and DFA reporting samples code.

Step 3: I download the client secret json file from Step 1 and copy in DFA reporting sample code.

Step 4: I am getting following the error while running index.php file from the DFA reporting sample code folder.  

{ "error": { "errors": [ { "domain": "global", "reason": "authError", "message": "Invalid Credentials", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Invalid Credentials" } }


Can you please help us to resolve this issue?

Thanks!

Lakshmi(DCM API Team)

unread,
Oct 26, 2016, 3:59:36 PM10/26/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

One possibility of this error could be when you are logging in as a different user (different email) when generating the access token. Could you please retry this by making sure that you are logged in as the correct user? Also, please double check if you have enabled the DCM/DFA Reporting And Trafficking API in the console.

Thanks,
Lakshmi, DCM API Team

Abhijit Bhosale

unread,
Oct 27, 2016, 8:50:00 AM10/27/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

I have checked with correct user log in. An user have DFA UI account as well as  DCM/DFA Reporting And Trafficking API enabled in the console. But still I have facing same error 'Invalid Credentials'.

I have created web application project in console. Is it okey with that?
Please help me to solved this issue.
Thanks!

Lakshmi(DCM API Team)

unread,
Oct 27, 2016, 12:36:33 PM10/27/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

Did you regenerate the token? Double check if you replaced the contents of client_secrets.json with your developer credentials.

The PHP samples are written for web application. So, it should be fine.

Thanks,
Lakshmi, DCM API Team

Abhijit Bhosale

unread,
Oct 28, 2016, 5:30:56 AM10/28/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

Thanks for your response.
Yes, I did generate access token. A getAccessToken() method from index.php gives me access token successfully.
Also I have checked the credentials contents from developer Console and in the client_secrets.json file from package are the same.
But still I am getting same error. I have to implement DFA API. 
A previous version 2.3 was working for same user but that is deprecated now.


Thanks!

Abhijit Bhosale

unread,
Oct 28, 2016, 10:12:15 AM10/28/16
to Google's DoubleClick Campaign Manager API Forum
Hello Lakshmi,

One more thing when I have uploaded code to another server, its working successfully for getting data couple of times
and then after some time the same error is occurs.
Then why this working for that couple of time and then not?

Do i need anything more to solve this issue? 
Thanks!

Lakshmi(DCM API Team)

unread,
Oct 28, 2016, 12:01:25 PM10/28/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

That's strange! Could you please log the failing request and see what is being sent in the request especially the access token? Also, please double-check if you are caching the access token on a local storage disk. If so, clear the cache and see if it works.

Abhijit Bhosale

unread,
Nov 2, 2016, 9:21:56 AM11/2/16
to Google's DoubleClick Campaign Manager API Forum
Hello,

I have also tried API calling after clearing the cache but still facing same error. I have attached the piece of response that contains object of response class which is showing error is 'invalid_token'. (Line 15), But in closure class object there is generated access token is showing.

Thanks!
ResponseObject.txt

Lakshmi(DCM API Team)

unread,
Nov 2, 2016, 4:17:28 PM11/2/16
to Google's DoubleClick Campaign Manager API Forum
Hi,

This error generally occurs if the access token has expired. Since that didn’t help, can you double check the following things? We have already crossed out few of these items as the probable cause, but I just want to be sure that we haven’t missed anything. 
  1. Make sure the client_Id and the client_secret mentioned in the client_secrets.json file is correct
  2. Double check that the refresh token is generated and is stored locally in the token.dat file (filename and path is specified in the index.php file)
  3. If the refresh and access token is stored locally, clear the cache by deleting the token.dat file and regenerate the tokens. Make sure you are logged in as the correct user while regenerating the token and the DCM scope is set correctly.
  4. Log the HTTP request and check if the access token is being passed correctly in the HTTP header
Thanks,
Lakshmi, DCM API Team

Vincent Crescente

unread,
Nov 19, 2019, 11:59:41 AM11/19/19
to Google's DoubleClick Campaign Manager API Forum
Can I please have a link where/how to do number 3.

DCM API (DoubleClick Campaign Mgr)

unread,
Nov 19, 2019, 3:41:23 PM11/19/19
to vcres...@gmail.com, google-doubleclick-...@googlegroups.com
Hi,

In your application if you are saving tokens you need to clear those values and regenerate the tokens. If you are using installed application or application type of other, then during browser launch (manual step for authorization) make sure you logged in with the email id that is associated with the given profile id. Please check the following link for index.php file:
https://github.com/googleads/googleads-dfa-reporting-samples/blob/master/php/v3.3/index.php

Helpful links:
  1. OAuth guide: https://developers.google.com/identity/protocols/OAuth2InstalledApp
  2. DCM Authorization guidehttps://developers.google.com/doubleclick-advertisers/authorizing
  3. Browser step (under Running the samples): https://github.com/googleads/googleads-dfa-reporting-samples/blob/master/php/v3.3/README.md
Thanks,
Lakshmi, DCM API Team
 

ref:_00D1U1174p._5001UOCeiG:ref
Reply all
Reply to author
Forward
0 new messages