AdWords Scope: gapi.client.adwords missing after authenticating with OAuth flow. Cannot find path variable to pass to gapi.client.request()
I followed this guide to create a web app flow for authenticating users with Google.
Despite listing https://www.googleapis.com/auth/adwords
in the scope parameter, I don't get a gapi.client.adwords
or anything like that once the authentication is complete. I am unable to retrieve any information about the user's MCC/AdWords/Ad Manager accounts.
I've tried using gapi.client.request()
but I can't seem to find the arguments that I should pass for access to the AdWords API.
I'm trying to do something like this:
let __req = gapi.client.request({ method: "GET", path: "/adwords/v?/???", params: { fields: "???" } }); __req.execute(function(response) { console.log(response); });
... or like this:
console.log(gapi.client.adwords)
but I can't figure out what I need to pass to gapi.client.request
and gapi.client.adwords
doesn't exist.
Is it possible that I'm not passing a discoveryDoc
or something like that? Where is the discoveryDoc
for AdWords?
scope: "https://www.googleapis.com/auth/adwords", discoveryDocs: ["???"]
Use Case: I'm trying to get a list of MCC/AdWords/Ad Manager accounts (specifically their ID's and names) that are associated with (or owned by) the authenticated user.
Thanks in advance!
The Google Ads / Adwords API is pretty different from many other Google interfaces in that it isn't open to the general public and can't be accessed with the "normal" API client libraries.
In order to interact with the Ads API (same goes for the older Adwords API) and access production accounts, you are required to present a valid developer token. To obtain one, you'll need to sign up for access as described here. Note that you'll get a developer token immediately, but you will only be able to access test accounts until your application has been verified.
Once you have a developer token, it's recommended to use the official client libraries:
Ads API client libraries (REST-based, currently in Beta, will supersede the Adwords API going forward) Adwords API (SOAP-based, still recommended for production)Unfortunately neither API currently offers official JS client libraries.
I have a valid production developer token and I'm using the server-side Node.js client library github.com/googleapis/google-api-nodejs-client. Important: Is there any way to actually get the AdWords user's CCID(s) from the OAuth flow? I tried the Ads API but I couldn't get it to work since I couldn't find any documentation for a JS client library, however, I was able to find a Node wrapper on NPMjs.org and that's what I'm currently using: npmjs.com/package/node-adwords
If the Ads API is REST-based, then there must be some sort of endpoint for retrieving the user's CCID(s) or possibly a client for the AdWords scope that can provide me with the user's CCID programmatically. Again, I can try to switch to the Ads API (instead of the AdWords API), but is it even possible to get that data from that API?
I would imagine something like OAuth flow > refresh token > Ads API getAccounts() or something like that
@ihodonald, the OAuth flow won't give you the account IDs. In the Ads API, you'll need to use the CustomerService.ListAccessibleCustomers function for that. For the Adwords API, it's CustomerService.getCustomers.
Thank you so much! I knew I was just missing something!