Google Ads API 服务帐号认证 net core 3

时间:2021-02-17 19:13:44

标签: c# .net-core google-ads-api

尝试使用此代码向 Google Ads API 发送事件后:

UploadClickConversionsResponse response =
    conversionUploadService.UploadClickConversions(
        new UploadClickConversionsRequest()
        {
            CustomerId = customerId.ToString(),
            Conversions = { clickConversion },
            PartialFailure = true,
            ValidateOnly = false
        });

我收到消息:

RpcException: Status(StatusCode="Unavailable", Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin. Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"invalid_request", Description:"Missing required parameter: refresh_token",  ...... 

之后,我尝试使用 ServiceAccountCredential 请求令牌,该令牌在此函数中返回“true”:

credential.RequestAccessTokenAsync(CancellationToken.None).Result;

但是还是不行。 谁能解释一下我如何配置 refresh_token 并将其与 UploadClickConversions 一起发送?

在这个链接 https://github.com/googleads/googleads-dotnet-lib/wiki/API-access-using-own-credentials-(server-to-server-flow)#step-2---setting-up-the-client-library

他们说我应该使用 app.config 中的配置,但我使用的是 net core 3.1,配置文件是 appsettings.json。

我完全被困住了。谢谢。

0 个答案:

没有答案