提问人:naenae0210 提问时间:8/2/2023 更新时间:8/2/2023 访问量:46
我正在使用 androidpublisher。NewService,以使用 Google Play 开发者 API。以下哪种方法是正确的?
I'm using the androidpublisher.NewService from the Go package to use the Google Play developer API. Which of the following methods is correct?
问:
我发现似乎有两种方式可用。以下哪种方法是正确的?
- Androidpublisher 中。NewService(ctx, 选项.WithHTTPClient(...))
func (_this *Factory) AccessToGoogle() (fac *Factory) {
ctx := context.Background()
jsonKey, err := ioutil.ReadFile(fac.property.GoogleAPIKey)
if err != nil {
fmt.Println("Can't read the API Key file")
return
}
config, err := google.JWTConfigFromJSON(jsonKey, androidpublisher.AndroidpublisherScope)
if err != nil {
fmt.Println("Can't get jwt config")
return
}
client := config.Client(ctx)
GoogleAPI, err := androidpublisher.NewService(ctx, option.WithHTTPClient(client))
if err != nil {
fmt.Println("Can't androidpublisher service")
return
}
fac.GoogleAPI = GoogleAPI
return fac
}
- Androidpublisher 中。NewService(ctx, 选项.WithCredentialsFile(...)
func (_this *Factory) AccessToGoogle() (fac *Factory) {
ctx := context.Background()
GoogleAPI, err := androidpublisher.NewService(ctx, option.WithCredentialsFile(GoogleAPIKey)
if err != nil {
fmt.Println("Can't androidpublisher service")
return
}
fac.GoogleAPI = GoogleAPI
return fac
}
创建JWT是必要的吗?或者只是使用该选项。WithHTTPClient 而不创建 jwtconfig 可以吗?
答: 暂无答案
评论