Posts tagged with google-cloud-platform

I made a script using Google Ads API to get reports from Google Ads. But the refresh token expires every 7 days. I found out that it happens because the app should be published (have publishing status "In production" instead of "Testing"). So I did it. But then the Verification status changed to "Needs verification". An option "Prepare for verification" appears

If I try to "Prepare for verification" than it requires to authorize domain of my app. So this is an option for cases when someone wants to make an app for multiple users.

But it's not my case, I just get reports from my own Google Ads account. I found out that probably the problem could be solved if I change User type of my app from "External" to "Internal". But it seems that it only an option for Google Workspace users.

But as I see on their site it is not free.

I am sure there should be some free option how to do this. Everything else works fine, the problem is just the refresh token expiration. Maybe I missed something, please help.

I created a test manager account and tried to get metrics for this account. But I getting an error as :

The developer token is not approved. Non-approved developer tokens can only be used with test accounts.

So I tried to create a customer account on Web GUI but in this time a getting an error like that:

Billing setups can not be used based on current status of the customer.

So I checked my accounts and the GUI like that:

So, How can I create a customer account from this test manager account?

I want to modify these API calls to use a GCP service account instead of my identity.

var report = AdsApp.search(searchQuery);    var table = BigQuery.Tables.insert(table, projectId, dataSetId); BigQuery.Jobs.insert(job, BIGQUERY_PROJECT_ID); 

I read this article but wasn't sure how to find the url for AdsApp and BigQuery.

I searched this post, but still haven't been sure.

Hi,

I want to write an Ads-script to call GoogleAds url nad BQ url using a service account.

I saw this code. Are my urls to the GAds and BQ api correct?

Thanks!

=====================

  // Natural Language API Sentiment URL   var url =       'https://language.googleapis.com/v1beta1/documents:analyzeEntities';   var options = {     method: 'POST',     contentType: 'application/json',     payload: JSON.stringify(body)   };   var response = authUrlFetchApp.fetch(url, options);   var result = JSON.parse(response.getContentText());   Logger.log(result);   if (result.entities) {     // return a list of identified entities     return result.entities;   }   throw Error('No entities response returned'); } 

I just started using GCP and can't create a data transfer from Ads. I did all steps by this documentation but I always get an issue without any explanation.

There was a problem saving this transfer config This transfer config could not be saved. Please try again. iq 

sometimes these two letters change, as far as I remember to 'jk'

Im building an app with google ads api using a service account auth flow (server to server).

The problem: the auth part is not working... I keep getting a 401 error.

Sample of the request:

const request = require('request'); .... request({   'method': 'GET',   'url': 'https://googleads.googleapis.com/v6/customers/XXXXXXXX',   'headers': {     'Authorization': 'Bearer XXXXXXXX',     'developer-token': 'XXXXXXXX',     'Content-Type': 'application/json'   } }) ... 

or

curl --location --request GET 'https://googleads.googleapis.com/v6/customers/XXXXXXXX' \ --header 'Authorization: Bearer XXXXXXXX' \ --header 'developer-token: XXXXXXXX' \ --header 'Content-Type: application/json' 

[ERROR] Response from google ads api:

{         "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 cant seem to find out why Im getting this authentication error.

What I have tried:

  1. Following this guide step by step -> https://developers.google.com/google-ads/api/docs/oauth/service-accounts
  2. Using the python library -> https://github.com/googleads/googleads-python-lib
  3. Using the google ads API with REST (no library)
  4. On localhost server
  5. On the production server (the www.g-suite.com domain linked to the account)

Whatever method or environment I try, it results in the same error.

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential 

Steps I have implemented:

  • Created a google ads manager account
  • Generated a valid developer token for that account
  • Created project in Google cloud platform
  • Opened a service account inside the project
  • Created a private key for the service account
  • Granting impersonation abilities in the G Suite domain for this scope: https://www.googleapis.com/auth/adwords
  • Enabled domain-wide delegation on the service account
  • Generated the access token with the key json file.

Generating the access token:

const { google } = require('googleapis'); const getAccessToken = async () => {     const SCOPES = ['https://www.googleapis.com/auth/adwords'];     const authClient = new google.auth.GoogleAuth({         keyFile: './pathtokeyfile.json',         scopes: SCOPES,     });     const token = await authClient.getAccessToken();     return token; }; 

I am surely missing something, but am not sure what it is..

Will be super grateful if someone can share a solution!! thanks champs 👍