About the use of Google Ads API to obtain billing information

98 views
Skip to first unread message

吉田航

unread,
Apr 27, 2022, 9:25:42 PM4/27/22
to Google Ads API and AdWords API Forum
hello.

I am thinking of downloading my monthly invoices by "invoices" in Google Apds API.
https://developers.google.com/google-ads/api/rest/reference/rest/v10/customers.invoices/list

However, when I run it, I get an error "PERMISSION_DENIED".
If there is no record specified, it should return that error, but if it is an authorization error, I am having trouble figuring out what to allow.

I am running it in Google AppScript (GAS), but I am not sure what I am missing or what permissions I should allow.

Please let me know if there is anything I am missing or if I have any permissions:
=============================================
  const billingSetup = `customers/${customerId}/billingSetups/${billing_Setup}`;
  const url = `https://googleads.googleapis.com/v10/customers/${customerId}/invoices?billingSetup=${billingSetup}&issueYear=${issueYear}&issueMonth=${issueMonth}`;
  const headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer " + access_token,
    "developer-token": developer_token,
    "login-customer-id": mcc_account
  };
  Logger.log(headers);
  Logger.log("url : " + url);
  const options = {
    "method": "get",
    "headers": headers,
  };
  const httpResponse = UrlFetchApp.fetch(url, options);
  const status = httpResponse.getResponseCode();
  if (status ! == 200) {
    throw "HttpRequestError";
  }
  const response = JSON.parse(httpResponse.getContentText());
=============================================

error:
=============================================
   
Exception: Request failed for https://googleads.googleapis.com returned code 403. Truncated server response: {
  "error": {
    "code": 403,
    message": "The caller does not have permission",
    "status": "PERMISSION_DENIED",
    "details": [
      {
 ... (use muteHttpExceptions option to examine full response)
=============================================

Thank you for your cooperation.

Google Ads API Forum Advisor

unread,
Apr 28, 2022, 11:51:25 PM4/28/22
to w.yo...@hitokuse.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to us.

Since you have encountered the AuthorizationError.USER_PERMISSION_DENIED error, The authorized customer does not have access to the operating customer, please ensure that you are specifying login-customer-id in the request while authenticating as a user with access to a manager account. To prevent this, make sure to specify the login-customer-id as the manager's account ID without hyphens (-). Client libraries have built in support for this, or see our guide.

For this error, you can check this documentation for more details.

If the issue persists after the recommended periods, you may provide complete API logs privately (request and response with request-id ) so our team can further check.

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


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