Request is missing required authentication credential Google Ads API beta

2,061 views
Skip to first unread message

anirudh maddy

unread,
Oct 11, 2018, 7:14:33 AM10/11/18
to AdWords API and Google Ads API Forum

                                var newAcessToken = getGoogleAccessToken(refresh_token);

                                var bearerToken = 'Bearer '+ newAcessToken;

                                var  options = {
                                  url: url,
                                  headers: {
                                    'Authorization': bearerToken,
                                    'Accept': '*/*',
                                    'developer-token':  myDevToken
                                  },
                                };


                               request(options, function(err, response) {

                                 if(err)
                                 {
                                     console.log(err);

                                 }
                                 else
                                 {
                                     console.log(response.body);
                                     res.end();
                                 }

                              });

Teja Makani

unread,
Oct 11, 2018, 2:11:40 PM10/11/18
to AdWords API and Google Ads API Forum
Hello Anirudh,

Could you please confirm whether you are following the steps shown here to generate refresh token? You could generate the access token from your refresh token using the below command (you can run it from terminal). Could you please elaborate what is the myKey in your line 'https://googleads.googleapis.com/v0/customers/myCustomerId?key=myKey';' ?

curl --data ""grant_type=refresh_token""      --data ""refresh_token=enter_your_refresh_token_here""      --data ""client_id=enter_your_client_Id_here""      --data ""client_secret=enter_your_client_secret_here""      https://www.googleapis.com/oauth2/v4/token

After the successful execution you will receive the access token valid till the next 60 minutes. Now try to run the below command to get the campaigns of your account.

curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN"      -H "developer-token: YOUR_DEVELOPER_TOKEN"      -H "Content-Type: application/json"      https://googleads.googleapis.com/v0/customers/YOUR_CLIENT_CUSTOMER_ID/googleAds:search      --data '{query: "SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id"}'

If you are still facing issues please share the error log and elaborate the scenario you are trying.

Regards,
Sai Teja, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages