Although, I have successfully implemented Google Keyword Planner API to generate Keyword Ideas in PHP with the link below.

https://developers.google.com/google-ads/api/docs/keyword-planning/generate-keyword-ideas

Does anyone know the fastest way to sort the result by AvgMonthlySearches?

// Iterate over the results and print its detail. foreach ($response->iterateAllElements() as $result) {     /** @var GenerateKeywordIdeaResult $result */     // Note that the competition printed below is enum value.     // For example, a value of 2 will be returned when the competition is 'LOW'.     // A mapping of enum names to values can be found at KeywordPlanCompetitionLevel.php.     printf(         "Keyword idea text '%s' has %d average monthly searches and competition as %d.%s",         $result->getText(),         is_null($result->getKeywordIdeaMetrics()) ?             0 : $result->getKeywordIdeaMetrics()->getAvgMonthlySearches(),         is_null($result->getKeywordIdeaMetrics()) ?             0 : $result->getKeywordIdeaMetrics()->getCompetition(),         PHP_EOL     ); } 

Thanks

I'm using oAuth2.0 flow to work with Google Ads API. I ran in a problem today that when doing an API Request I'm getting the following 401 error:

UNAUTHENTICATED: 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. 

On the headers of each google ads request I add

   {"Content-Type", "application/json"},    {"Accept", "application/json"},    {"User-Agent", "Mozilla/5.0 (Macintosh; ..."},    {"Authorization", "Bearer $ACCESS_TOKEN"},    {"developer-token", "$DEVELOPER_TOKEN"},    {"login-customer-id", "$LOGIN_CUSTOMER_ID"} 

I've already tried to generate a new access_token, since my automatically process of generating new access_tokens when the current one expired could be failing, but it wasn't the case. I managed to create a new valid access token and it continues to give the same error. The scope used when fist granted permissions to the app was "https://www.googleapis.com/auth/adwords".

Did anyone fall into the same problem?

I'm trying to run the keyword stats report (file found here: https://github.com/googleads/google-ads-python/blob/master/examples/reporting/get_keyword_stats.py) via the Google Ads API. I have the googleads.yaml file setup already. But when I run the report, I'm getting an error that says:

ValueError: A required field in the configuration data was not found. The required fields are: ('developer_token',) 

I have all the required fields in my googleads.yaml file. Please see screenshot below for reference. What could have gone wrong in my code? Why is it not reading the 'developer_token' I have in the googleads.yaml file?

i am using java library client for web application authentication, i produce authorization url using client secret and client id,also i provided a redirect url within google api console,but i don't know if it is necessary for me to create this server to receive refresh token? i mean in production i should provide a separate server to receive the refresh token?(redirect url comes to this server) the main problem is user should paste the produced url on browser by himself but i want to open browser authmaticly , the second one is about reciving the refresh token i am not sure about creating another server to recieve refreshcode and i can't use service accounts i am going with web flow authentication.

 UserAuthorizer userAuthorizer =                 UserAuthorizer.newBuilder()                         .setClientId(ClientId.of(clientId, clientSecret))                         .setScopes(SCOPES)                         .setCallbackUri(URI.create(OAUTH2_CALLBACK_URL_CONFIGURED_AT_GOOGLE_CONSOLE))                         .build();         baseUri = URI.create("http://localhost:" + simpleCallbackServer.getLocalPort());         System.out.printf(                 "Paste this url in your browser:%n%s%n",                 userAuthorizer.getAuthorizationUrl(loginEmailAddressHint, state, baseUri)); 

and this is local server to receive refresh token:

private static class SimpleCallbackServer extends ServerSocket {         private AuthorizationResponse authorizationResponse;         SimpleCallbackServer() throws IOException {             // Passes a port # of zero so that a port will be automatically allocated.             super(0);         }         /**          * Blocks until a connection is made to this server. After this method completes, the          * authorizationResponse of this server will be set, provided the request line is in the          * expected format.          */         @Override         public Socket accept() throws IOException {             Socket socket = super.accept();         } } 

I want to fetch ad group performance report with two demographics, gender and age_range, also with other metrics. So I used gender_view with query body below, but found the information of age_range are all "UNSPECIFIED". By the way, age_range_view is the same result which the information of gender are all "UNSPECIFIED".

SELECT     segments.date,     campaign.name,     ad_group.name,     ad_group_criterion.criterion_id,     ad_group_criterion.age_range.type,     ad_group_criterion.gender.type,     metrics.impressions,     metrics.clicks,     metrics.cost_micros,      metrics.conversions FROM age_range_view WHERE segments.date BETWEEN "2021-01-01" AND "2021-04-30" 

Is there any good method to query?