developer-token parameter is missing even though I'm passing the token in Google Ads API

2,245 views
Skip to first unread message

anirud...@gmail.com

unread,
May 7, 2019, 6:33:54 AM5/7/19
to AdWords API and Google Ads API Forum
I'm passing the Developer Token in the GET request to fetch the MCC accounts. But I keep getting the below error even though I'm passing the required information.


    
"message": "developer-token parameter is missing


I tried making the request in different ways. But I'm unable to figure it out. Code is in Node JS 

V1: GET request 

var options = {
            url: 'https://googleads.googleapis.com/v1/customers:listAccessibleCustomers',

               auth: {
                'bearer': access_token,
                    'developer-token':'XXXX_XXXXXXXXXX'
                 }

            };

        console.log('Access Token is - ', access_token);

        request(options, function(err, response) {
                console.log(response); 
            });



v2: GET request 

var bearerToken = 'Bearer '+ access_token;

 var options = {
           url: 'https://googleads.googleapis.com/v1/customers:listAccessibleCustomers',

           headers: {
              'Authorization': bearerToken,
              'developer-token': 'XXXX_XXXXXXXXXX'
                }

        };



    request(options, function(err, response) {
                console.log(response); 
         });


googleadsapi...@google.com

unread,
May 7, 2019, 2:05:35 PM5/7/19
to AdWords API and Google Ads API Forum
Hello Aniruth,

If you are looking to get the accounts under your manager account you have to use the resource customer_client instead. The error message you are seeing will occur when the developer token is not passed to the API call properly. Since our client libraries will support the languages mentioned here only, I don't have any Node Js examples. But I can give you the sample CURL operation that you can perform from your terminal and build you Node Js code by referring them.

Sample CURL code to get accounts linked to your manager account:

curl -H "Authorization: Bearer Access_token"
       -H "developer-token: DeveloperToken"
       -H "Content-Type: application/json" https://googleads.googleapis.com/v1/customers/MCC_ID/googleAds:search
       --data '{query: "SELECT customer_client.resource_name, customer_client.client_customer, customer_client.level, customer_client.hidden FROM customer_client"}'

Sample CURL operation to get the accessible customers from the OAuth credentials:

curl -H "Authorization: Bearer Access_Token"
       -H "developer-token: Developer_Token"
       -H "Content-Type: application/json" https://googleads.googleapis.com/v1/customers:listAccessibleCustomers

Could you please give it a try and let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/dd3f1a29-c719-4f81-811c-12239882b10f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

anirudh maddy

unread,
May 8, 2019, 7:45:51 AM5/8/19
to AdWords API and Google Ads API Forum
I tried it with curl by passing the below command

curl --header "Authorization: Bearer MYACCESSTOKEN" --header "developer-token: MYDEVTOKEN"  --header "Content-Type: application/json"  https://googleads.googleapis.com/v1/customers:listAccessibleCustomers

I got this as a response

{


  "error": {


    "code": 401,


    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",


    "status": "UNAUTHENTICATED"


  }


}


I'm passing the correct OAuth2.0 Access Token. What could be the issue here?

googleadsapi...@google.com

unread,
May 8, 2019, 11:36:26 AM5/8/19
to AdWords API and Google Ads API Forum
Hello Aniruth,

Usually, the access token has certain time limit after that time it will be invalidated and you have to generate another access token to work with. I faced the similar error when I pass the expired access token to the API call.

If you have a refresh token with you, you can generate access token using that refreshtoken whenever the access token is expired(If you are using our client libraries they will manages this functionality internally). To generate access token from refresh token you can use the below sample CURL operation. If don't have a refresh token you can create new set of credentials by following this guide.

Sample Curl operation to generate access token from refresh token:

curl --data ""grant_type=refresh_token""      
       --data ""refresh_token=REFRESH_TOKEN_HERE""      
       --data ""client_id=CLIENT_ID_HERE""      
       --data ""client_secret=CLIENT_SECRET_HERE""      

Regards,
Sai Teja, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

anirudh maddy

unread,
May 9, 2019, 1:54:07 AM5/9/19
to AdWords API and Google Ads API Forum
Hello Sai, 

I'm following the exact thing, I'm generating the access_tokens using a refresh token if they expire. I used the same code to Integrate Google Analytics, Google Search, YouTube Reporting. It worked fine with all the APIs, only with Google Ads API I'm facing this issue. Is there any Google Web Tool, to test the Google Ads API just the Google Analytics Tool - https://ga-dev-tools.appspot.com/query-explorer/

googleadsapi...@google.com

unread,
May 9, 2019, 3:17:05 PM5/9/19
to AdWords API and Google Ads API Forum
Hello Aniruth,

You could try using the OAuth 2.0 Playground where you can perform the similar request. Attached screenshot of my sample request for your reference, please give it a try and let me know if the request is not going through. The error ur are facing is related to not passing the authorization properly.

Regards,
Sai Teja, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Oauth Playground.png

anirudh maddy

unread,
May 9, 2019, 10:56:28 PM5/9/19
to AdWords API and Google Ads API Forum
Hello Sai, 

I have followed the same procedure. Please find the attached screenshots for the steps I followed. 

Screenshot1.png

Screenshot2.png

Screenshot3.png

Screenshot4.png

Screenshot5.png

googleadsapi...@google.com

unread,
May 10, 2019, 3:22:08 PM5/10/19
to anirud...@gmail.com, AdWords API and Google Ads API Forum
Hi Anirudh,

Thanks for the question, and sorry you're running into this issue. As you're going through the OAuth playground, did you create a new project or are you using the one you created previously when writing your Node script? Just curious because when creating credentials for use in a software application you usually need to select an application type of "other" whereas the playground asks you to create an application type of "web application."

Sometimes the mismatch can cause issues.

Thanks,
Ben Karl, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

anirudh maddy

unread,
May 12, 2019, 1:29:53 AM5/12/19
to AdWords API and Google Ads API Forum
Hi, 


I'm using the project created previously for Node (Type - Web Application). 

However, as you suggested I created a new Project with Type - Others. Tried it with OAuth2.0 Playground. 

I'm getting the below error. 

GAdsError.png



On Tuesday, 7 May 2019 16:03:54 UTC+5:30, anirudh maddy wrote:

googleadsapi...@google.com

unread,
May 13, 2019, 10:21:35 AM5/13/19
to anirud...@gmail.com, AdWords API and Google Ads API Forum
Hi Anirudh,

That error means that the developer token and the client-id/client-secret from your Google Could project can't be used in the same request.

For a given Google Cloud project ID, the Google Ads API only allows you to use one developer token. When you receive the above error it usually means that in the past there was at least one request to the Google Ads API using OAuth credentials from the same project ID and a different developer token.

The most straightforward way to resolve this is to create a new Google Cloud project ID, obtain OAuth credentials from a client under the new project ID, and use those credentials in your requests with your developer token.

Hope that helps!

Best,
Ben Karl, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
Reply all
Reply to author
Forward
0 new messages