Google Ads Api Console Application
I want to develop a console application that pulls all campaigns under adwords accounts using Google Ads Api. But I could not pass the authentication step.
I do not fully understand whether I should use the Service Account or Desktop Application Flow for this process.
GoogleAdsConfig config = new GoogleAdsConfig() { DeveloperToken = "Dev_token", OAuth2Mode = Google.Ads.GoogleAds.Config.OAuth2Flow.APPLICATION, OAuth2ClientId = "client_Id", OAuth2ClientSecret = "secrret", OAuth2RefreshToken = " refresh_token", }; GoogleAdsClient client = new GoogleAdsClient(config); GoogleAdsServiceClient googleAdsService = client.GetService(Google.Ads.GoogleAds.Services.V10.GoogleAdsService); googleAdsService.SearchStream(AdwordsClientId, query, delegate (SearchGoogleAdsStreamResponse resp) { foreach (GoogleAdsRow adsRow in resp.Results) { } } );
When I try as above, I get the following error
Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"unauthorized_client", Description:"Unauthorized", Uri:""
What paths should i follow? Thank you.
unauthorized_client could have a couple of reasons. The most important ones that come to mind:
Did you make sure that your client ID and client secret match? Have you activated the Google Ads API for the GCP project whose OAuth2 client you are using?