googleapis / google-auth-library-nodejs

🔑 Google Auth Library for Node.js
Apache License 2.0
1.73k stars 383 forks source link

fix: add missing return value to `fromAPIKey` #1837

Closed hansemannn closed 4 months ago

hansemannn commented 4 months ago

According to the docs, the fromAPIKey function should return an instance of the class again, but returns void in the actual code.

To properly use it in chaining scenarios, e.g. const client = new JWT().fromAPIKey('<api-key>'), this issue should be addressed.

danielbankhead commented 4 months ago

The docs are referencing GoogleAuth, which generates a JWT:

https://github.com/googleapis/google-auth-library-nodejs/blob/0b78d91534d97b37859a2303b332f8ccd52dbf69/src/auth/googleauth.ts#L806-L817

Sample usage:

import {GoogleAuth} from 'google-auth-library';

const key = '';

const auth = new GoogleAuth();
const client = auth.fromAPIKey(key);