如何初始化Android发布服务器以访问google API?我知道我可以使用原始的googleapis包,但是我的服务器在导入该包时内存不足,因此我只使用了@googleapis/androidpublisher包。
我不知道如何将正确的'auth‘传递给出版商,这样我就可以充分验证。我正在使用google自述的服务帐户凭据文件:

此代码不起作用。
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'
的单独声明
发布于 2022-10-17 10:54:47
这需要像这里提到的那样做: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 })https://stackoverflow.com/questions/74090753
复制相似问题