小编Art*_*555的帖子

如何在 Google Play 开发者报告 API 中设置令牌范围

我开始使用 Golang 来使用 Google Play 开发者报告 API(https://pkg.go.dev/google.golang.org/api@v0.79.0/playdeveloperreporting/v1beta1),并面临与 API 范围相关的问题:

代码:

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "golang.org/x/oauth2"
    "golang.org/x/oauth2/google"
    "golang.org/x/oauth2/jwt"
    "google.golang.org/api/option"
    "google.golang.org/api/playdeveloperreporting/v1beta1"
    "io/ioutil"
)

const (
    GoogleApplicationCredentials = "path_to_service_account_credentials"
    ProjectID                    = "apps/{project_id}"
)

func main() {
    tokenSource, err := getTokenSource(GoogleApplicationCredentials)
    if err !=nil {
        panic(err)
    }
    if err := getAnomalies(tokenSource, ProjectID); err != nil {
        panic(err)
    }
}

func getAnomalies(tokenSource oauth2.TokenSource, projectID string) error {
    ctx := context.Background()
    service, err := playdeveloperreporting.NewService(ctx, option.WithTokenSource(tokenSource))
    if err != nil { …
Run Code Online (Sandbox Code Playgroud)

google-api go google-play-developer-api google-api-go-client

5
推荐指数
1
解决办法
773
查看次数