调用 Dynamic Links Analytics API 时调用者没有权限 [403]

The caller does not have permission [403] when calling Dynamic Links Analytics API

我正在尝试使用方法 FirebaseDynamicLinksService.V1.GetLinkStats() 通过动态链接分析 API 获取动态 link 统计信息...我能够轻松地创建一个简短的 link它有效...但问题是获取有关此动态 link.

的统计信息

我得到了 403: “Google.Apis.Requests.RequestError 来电者没有权限【403】 错误 [消息[调用者没有权限] 位置[-] 原因[禁止] 域[全局]]"

有什么我想念的吗?我试着按照这个 https://firebase.google.com/docs/reference/dynamic-links/analytics

我的代码基本上是这样的:

var googleCredential = GoogleCredential.FromFile(shortLinkServiceConfiguration.KeyFileName).CreateScoped($"https://www.googleapis.com/auth/firebase");
var dynamicLinksService = new FirebaseDynamicLinksService(new Google.Apis.Services.BaseClientService.Initializer
        {
            HttpClientInitializer = googleCredential,
            ApplicationName = shortLinkServiceConfiguration.ApplicationName
        });

var request = dynamicLinksService.ShortLinks.Create(createShortDynamicLinkRequest);
request.AccessToken = googleCredential.UnderlyingCredential.GetAccessTokenForRequestAsync().Result;

// This works and I get the short link
var response = request.Execute();

var secondRequest = dynamicLinksService.V1.GetLinkStats(response.ShortLink);
secondRequest.AccessToken = googleCredential.UnderlyingCredential.GetAccessTokenForRequestAsync().Result;
secondRequest.DurationDays = 7;

// This does not work and I get 403 
var secondResponse = secondRequest.Execute();

所以在这里的帮助下:https://github.com/googleapis/google-api-dotnet-client/issues/1448

通过在服务帐户中添加 "Firebase Grow Viewer" 角色解决了问题...