Swi*_*ing 1 google-api node.js express google-play-developer-api google-developers-console
如何初始化 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: ["https://www.googleapis.com/auth/androidpublisher"],
})
});
Run Code Online (Sandbox Code Playgroud)
预期的类型来自属性“auth”,该属性在“GlobalOptions”类型上声明
类型“GoogleAuth”不可分配给类型“string |” 基本外部帐户客户端 | 谷歌验证 | 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.com/auth/androidpublisher"]
});
this.androidPublisher = new publisher.androidpublisher_v3.Androidpublisher({ auth: auth })
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1186 次 |
最近记录: |