Googleapis Service Account Authentication Gaxios Error

Viewed 176

I`m having some trouble during the purchase validation process using the Google Play Developer API. To be more precise, somewhere between the generation of the JWT token and the use of it.

private androidpublisher: any = google.androidpublisher({
  version: 'v3',
});

private authClient: JWT = new google.auth.JWT({
  email: key.client_email,
  key: key.private_key,
  scopes: ['https://www.googleapis.com/auth/androidpublisher'],
});

public async getSubscriptionPurchaseInfo(
  packageName: string,
  subscriptionId: string,
  token: string,
): Promise<any> {
  try {
    await this.authClient.authorize();
    return this.androidpublisher.purchases.subscriptions.get({
      auth: this.authClient,
      packageName,
      subscriptionId,
      token,
    });
  } catch ( error ) {
    throw new GoogleApiAuthenticationException(error.message);
  }

}

The error I`m getting -->

[Nest] 212   - 01/27/2021, 4:28:47 PM   [ExceptionsHandler] Invalid Value +913254ms
Error: Invalid Value
     at Gaxios._request (/app/node_modules/gaxios/build/src/gaxios.js:112:23)
     at processTicksAndRejections (internal/process/task_queues.js:93:5)
     at async JWT.requestAsync (/app/node_modules/google-auth-library/build/src/auth/oauth2client.js:343:18)

It seems to me the error is produced somewhere between the attempt to generate the JWT token and the use of it.

I`ve also tried -->

const auth = new google.auth.GoogleAuth({
  keyFile: '/path/to/your-secret-key.json',
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
0 Answers
Related