Posts tagged with google-api

customer_service = client.get_service("CustomerService") app_list = customer_service.list_accessible_customers().resource_names def customer_query(client, customer_id):     ga_service = client.get_service("GoogleAdsService")     query = """         SELECT             customer.descriptive_name,             customer.currency_code         FROM customer         LIMIT 1"""     request = client.get_type("SearchGoogleAdsRequest")     request.customer_id = customer_id     request.query = query     response = ga_service.search(request=request)     customer = list(response)[0].customer     return customer for entry in app_list:     customer_id = entry.split('/')[1]     entry = customer_query(client, customer_id)     formatted_entry = {'customer_id': customer_id, 'name': entry.descriptive_name, 'currency': entry.currency_code}     apps.append(formatted_entry) return apps 

This seems really convoluted and I'm having to pass around a lot more data than I'd like. Surely there should be a way to just request the details.

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 using Google Ads PHP library to create Campaign.

I created almost any type of campaigns but didn't manage to optimize them by specific Conversion Actions.

For example:

I have created 3 different Conversion Actions:

customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_0] customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_1] customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_2]

Then I created a Campaign:

customers/[CUSTOMER_ID]/campaigns/[CAMPAIGN_ID]

I set bidding strategy to MAXIMIZE_CONVERSIONS and then tried to set Conversion Actions to optimize to. This is my code snippet:

$campaign->setMaximizeConversions(   new CommonMaximizeConversions([     'target_cpa' => $this->convert()->micros(1)   ]) ); $campaign->setSelectiveOptimization(   new SelectiveOptimization([     'conversion_actions' => [       'customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_0]',       'customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_1]'     ]   ]) ); 

It gives me this error:

{     "message": {         "message": "Request contains an invalid argument.",         "code": 3,         "status": "INVALID_ARGUMENT",         "details": [             {                 "@type": "type.googleapis.com/google.ads.googleads.v10.errors.GoogleAdsFailure",                 "errors": [                     {                         "errorCode": {                             "requestError": "UNKNOWN"                         },                         "message": "The error code is not in this version.",                         "trigger": {                             "stringValue": ""                         },                         "location": {                             "fieldPathElements": [                                 {                                     "fieldName": "operations",                                     "index": 0                                 },                                 {                                     "fieldName": "create"                                 },                                 {                                     "fieldName": "selective_optimization"                                 },                                 {                                     "fieldName": "conversion_actions"                                 }                             ]                         }                     }                 ],                 "requestId": "xbgMUFFeP4447GFW_nJrIA"             }         ]     }, } 

Can you tell me what I am doing wrong? Or suggest any help?.

Thanks.

I am looking for the equivalents of Adwords API in the new Google ads API in PHP.

For example, the equivalent of

use Google\AdsApi\AdWords\v201809\cm\AgeRange; 

is

use Google\Ads\GoogleAds\V10\Common\AgeRangeInfo; 

But I can't find the exact equivalents for those for example:

use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSetting; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingNegativeGeoTargetType; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingPositiveGeoTargetType; 

Do you know any translators from google adwords to google ads?

I am trying to migrate Adwords API(sunset on 27th April, 2022) to Google Ads api. Using Asp.Net Core(5.0) and c#.

Exception: Google.Ads.GoogleAds.V10.Errors.GoogleAdsException HResult=0x80131500 Message=Status(StatusCode="Unauthenticated", Detail="Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",

I want to use "keywordPlanIdeaService" Can anyone have any suggestions.