首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >npm:如何使AndroidPublisher从googleapis中无效

npm:如何使AndroidPublisher从googleapis中无效
EN

Stack Overflow用户
提问于 2022-10-16 21:15:16
回答 1查看 42关注 0票数 0

如何初始化Android发布服务器以访问google API?我知道我可以使用原始的googleapis包,但是我的服务器在导入该包时内存不足,因此我只使用了@googleapis/androidpublisher包。

我不知道如何将正确的'auth‘传递给出版商,这样我就可以充分验证。我正在使用google自述的服务帐户凭据文件:

此代码不起作用。

代码语言:javascript
复制
import { androidpublisher_v3 as AndroidPublisherApi } from "@googleapis/androidpublisher";
import credentials from "../assets/google-play-console-service-account.json";

this.androidPublisher = new AndroidPublisherApi.Androidpublisher({
  auth: new GoogleAuth(
    {
      credentials, // Pass in the 'google-play-console-service-account.json' credentials
      scopes: ["https://www.googleapis.com/auth/androidpublisher"],
    })
});

预期的类型来自属性'auth‘,属性’auth‘在'GlobalOptions’类型' GoogleAuth‘上声明,而’GoogleAuth‘类型不能被指定为'string欧元/ BaseExternalAccountClient \GoogleAuth OAuth2Client’(未定义)。键入“GoogleAuth”不能输入“GoogleAuth”。类型具有私有属性'checkIsGCE'

的单独声明

EN

回答 1

Stack Overflow用户

发布于 2022-10-17 10:54:47

这需要像这里提到的那样做:https://googleapis.dev/nodejs/googleapis/latest/tasks/

代码语言:javascript
复制
const publisher = require("@googleapis/androidpublisher");

const auth = new publisher.auth.GoogleAuth({
  keyFilename: './api/assets/google-play-console-service-account.json',
  // Scopes can be specified either as an array or as a single, space-delimited string.
  scopes: ["https://www.googleapis.com/auth/androidpublisher"]
});
this.androidPublisher = new publisher.androidpublisher_v3.Androidpublisher({ auth: auth })
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74090753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档