最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

npm:如何从 googleapis 初始化 AndroidPublisher

网站源码admin36浏览0评论

npm:如何从 googleapis 初始化 AndroidPublisher

npm:如何从 googleapis 初始化 AndroidPublisher

如何初始化 Android 发布者以访问 google play 开发者 API?我知道我可以使用原始的

googleapis
包,但是我的服务器在导入该包时内存不足,因此我只使用了
@googleapis/androidpublisher
包。

我不知道如何将正确的“身份验证”传递给发布者,以便我可以进行充分的身份验证。我正在使用谷歌自述文件中提到的服务帐户凭据文件:

此代码无效。

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: [""],
    })
});

预期的类型来自属性“auth”,它在此处声明为类型“GlobalOptions”

类型“GoogleAuth”不可分配给类型“string | BaseExternalAccountClient |谷歌授权 | OAuth2客户端 |不明确的'。 类型“GoogleAuth”不可分配给类型“GoogleAuth”。 类型具有私有属性“checkIsGCE”的单独声明

回答如下:

这需要按照此处所述完成:https://googleapis.dev/nodejs/googleapis/latest/tasks/

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/auth/androidpublisher"]
});
this.androidPublisher = new publisher.androidpublisher_v3.Androidpublisher({ auth: auth })
发布评论

评论列表(0)

  1. 暂无评论