I was told to use a service account otherwise I would be using OAuth2/ClientSecret/Id/etc
Right now my code is very simple just trying to get it to authenticate and return some data.
var googleAdsConfig = new GoogleAdsConfig
{
DeveloperToken = "vcvcxvvxvxxcvxvxxc",
OAuth2Mode = OAuth2Flow.SERVICE_ACCOUNT,
OAuth2SecretsJsonPath = credentialsFilePath,
OAuth2Scope = "
https://www.googleapis.com/auth/adwords",
OAuth2PrnEmail = "star*********
serviceaccount.com"
};
var googleAdsClient = new GoogleAdsClient(googleAdsConfig);
// Get the Google Ads service
var googleAdsService = googleAdsClient.GetService(Services.V17.GoogleAdsService);
// Replace with your desired query
var query = @"
SELECT
campaign.name,
ad_group.status
FROM campaign
WHERE campaign.status IN (ENABLED, PAUSED)
";
// Execute the search request
var searchStreamResponse = googleAdsService.SearchStream("NNNNNN", query,
delegate (SearchGoogleAdsStreamResponse resp)
{
foreach (GoogleAdsRow googleAdsRow in resp.Results)
{
Console.WriteLine("Campaign with ID {0} and name '{1}' was found.",
googleAdsRow.Campaign.Id,
googleAdsRow.Campaign.Name);
}
}
);
I get the error
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."
thanks for your help,