How can I initialize the Android publisher to access the google play developer API? I know that I can use the raw googleapis
package but my server is running out of memory when importing that package thus I used the @googleapis/androidpublisher
package the only I need.
I don't know how to pass proper 'auth' to the publisher so I can authenticate adequately. I am using the Service account credentials file as mentioned in the google readme:
This code does not work.
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"],
})
});
The expected type comes from property 'auth' which is declared here on type 'GlobalOptions'
Type 'GoogleAuth' is not assignable to type 'string | BaseExternalAccountClient | GoogleAuth | OAuth2Client | undefined'. Type 'GoogleAuth' is not assignable to type 'GoogleAuth'. Types have separate declarations of a private property 'checkIsGCE'
This needs to be done as mentioned here: 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 })