I am trying to call Google Ad Manager Api for the first time in C#. Afer following the tutorial at https://developers.google.com/ad-manager/api/start
This is my code:
try
{
AdManagerUser user = new AdManagerUser();
using (NetworkService networkService = user.GetService<NetworkService>())
{
Network network = networkService.getCurrentNetwork();
Console.WriteLine($"Current network has network code {network.networkCode} and" +
$"display name {network.displayName}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
But it breaks at the first line with this exception:
Failed to load JSON secrets file for service account configuration. See inner exception for details."} System.Exception {Google.Api.Ads.Common.Lib.AdsOAuthException
In the App.config, this is the configuration:
<AdManagerApi>
<add key="MaskCredentials" value="true"/>
<add key="EnableGzipCompression" value="true"/>
<add key="IncludeUtilitiesInUserAgent" value="true"/>
<!-- Proxy settings for library. -->
<add key="ProxyServer" value=""/>
<add key="ProxyUser" value=""/>
<add key="ProxyPassword" value=""/>
<add key="ProxyDomain" value=""/>
<add key="ApplicationName" value="test_app"/>
<add key="NetworkCode" value="xxx"/>
<add key="AuthorizationMethod" value="OAuth2"/>
<add key="OAuth2ClientId" value="xxx"/>
<add key="OAuth2ClientSecret" value="xxx"/>
<add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
<add key="OAuth2SecretsJsonPath" value="C:\Secret\xxx.json" />
</AdManagerApi>