npm:如何从 googleapis 初始化 AndroidPublisher

编程入门 行业动态 更新时间:2024-10-07 00:16:41

npm:如何从 googleapis <a href=https://www.elefans.com/category/jswz/34/1767637.html style=初始化 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 })

更多推荐

npm:如何从 googleapis 初始化 AndroidPublisher

本文发布于:2024-05-30 06:30:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初始化   npm   googleapis   AndroidPublisher

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!