简体   繁体   中英

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

I am trying to get dynamic link stats via Dynamic Links Analytics API with the method FirebaseDynamicLinksService.V1.GetLinkStats() ... I was able to create a short link easily and it works... But the problem is to get the stats about this dynamic link.

I got 403: "Google.Apis.Requests.RequestError The caller does not have permission [403] Errors [Message[The caller does not have permission] Location[ - ] Reason[forbidden] Domain[global]]"

Is there something I am missing? I tried to follow this https://firebase.google.com/docs/reference/dynamic-links/analytics

My code basically looks like this:

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();

So with the help in here: https://github.com/googleapis/google-api-dotnet-client/issues/1448

The problem was solved with addition of "Firebase Grow Viewer" role in the service account...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM