Posts tagged with google-ads-api

I'm developing an application for a client that needs to be hosted in one of their systems.
I already have a developer token and a functioning API but it has access to every ad account I own under my MCC.

I would like to have a token that only has access to a restricted subset of ad accounts, as I obviously cannot share my full token with the client.

I have already tried the service account authentication but it doesn't anwswer my needs.

edit: any tips on sharing secrets is welcome if the functionality is not natively supported by the API

I'm obviously missing something really obvious. If I use the standard report I can analyse the data by gender very easily. If I download the data via the API I can't find a gender field at all. I have a LOT of tables, but no field named gender (or anything close) or a field that contains gender details.

What am I missing in my understanding?

We have an app with offline access_type token. Yesterday all queries were broken, because authorization failed

POST https://oauth2.googleapis.com/token 

resulted in a

400 Bad Request response: { "error": "invalid_grant", "error_description": "Bad Request" }).

We use SDK Google Ads API Client Library for PHP for any queries to API.

Code example:

// Generate a refreshable OAuth2 credential for authentication.         $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile($filePathName)->build();         $loggerFactory    = new LoggerFactory();         $logger           = $loggerFactory->createLogger('TestChannel',             APPLICATION_DIRECTORY . ".log/google/adsapi.date("Y-m").".log",             'DEBUG');         // Construct a Google Ads client configured from a properties file and the         // OAuth2 credentials above.         $googleAdsClient = (new GoogleAdsClientBuilder())             ->fromFile(std::lpath($filePathName))             ->withOAuth2Credential($oAuth2Credential)             ->withLogger($logger)             ->build();         $query = "SELECT customer_client.status FROM customer_client";         $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();         $response               = $googleAdsServiceClient->search(             $customerId,             $query,             ['pageSize' => self::PAGE_SIZE]         );         return $response->getIterator()->current();

App is in production in google cloud console.

What have we already done:

  • changed password for account
  • reset secret and generate new refresh token

Create new app isn't good solution for us, because I think, we couldn't quickly increase limits to API (but in this moment we were forced to use an app with basic limits and quota)

Any idea how to solve this problem or how contact Google oAuth team with this question?

Related to https://groups.google.com/g/adwords-api/c/nvLa0xPkdUs/m/0P3LcxBgAQAJ

Update: I had found, that there is no link to my app in https://myaccount.google.com/permissions Anyone know, how to add this permissions again?

I am trying to add users to the newly created audience in Google ads API but I am getting the following response from the API. I want to understand what is possibly causing this error and how to fix this?

Set<String> userList;  //this contains Hashed data(email of user that I want to upload)   List<UserDataOperation> userDataOperations = new ArrayList<>(userList.size());    for (String user : userList) {     UserDataOperation userDataOperationEmail = UserDataOperation.newBuilder().setCreate(         UserData.newBuilder()             .addUserIdentifiers(UserIdentifier.newBuilder().setHashedEmail(user).build())             .build()).build();     userDataOperations.add(userDataOperationEmail);    } 

I am trying to use a service account to connect with the Google Ads API.

At the momet my code looks like this:

$oAuth2Credential = (new OAuth2TokenBuilder())         ->withJsonKeyFilePath(self::CREDENTIALS_FILE_PATH)         ->withScopes('https://www.googleapis.com/auth/adwords')         ->withImpersonatedEmail(IMPERSONATED_EMAIL)         ->build();     $googleAdsClient = (new GoogleAdsClientBuilder())         ->withOAuth2Credential($oAuth2Credential)         ->withDeveloperToken(DEVELOPER_TOKEN)         ->build();     $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();     $query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id';     $stream =         $googleAdsServiceClient->searchStream(CUSTOMER_ID, $query); 

In Google cloud I have created a project and a service account. The account is the same I have access to at Google Ads. Also I have set the Domain-Wide Delegation at Google Workspace, with this same account. In my opinion I did everything right, but I am getting this error:

I hope there's someone who can help me out.