Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
I am trying to instantiate a Sqladmin class by passing a custom GoogleAuth object, which was in turn instantiated by passing a custom AuthClient object.
However, I get a TypeScript error shown below, which is due to the fact that Sqladmin class expects auth: GoogleAuth, which is defaulted to GoogleAuth<JSONClient>, where JSONClient = JWT | UserRefreshClient | BaseExternalAccountClient | ExternalAccountAuthorizedUserClient | Impersonated;
I believe that Sqladmin class should be parameterized with T extends AuthClient, and then it should accept GoogleAuth<T> in the auth property.
Code
import {AuthClient, GoogleAuth} from 'google-auth-library';
import {sqladmin_v1beta4} from '@googleapis/sqladmin';
const {Sqladmin} = sqladmin_v1beta4;
function buildSqlAdmin (authClient: AuthClient) {
const auth = new GoogleAuth<AuthClient>({
auth: authClient,
scopes: ['https://www.googleapis.com/auth/sqlservice.admin'],
});
return new Sqladmin({
auth
});
}
I am trying to instantiate a
Sqladmin
class by passing a customGoogleAuth
object, which was in turn instantiated by passing a customAuthClient
object.However, I get a TypeScript error shown below, which is due to the fact that
Sqladmin
class expectsauth: GoogleAuth
, which is defaulted toGoogleAuth<JSONClient>
, whereJSONClient = JWT | UserRefreshClient | BaseExternalAccountClient | ExternalAccountAuthorizedUserClient | Impersonated;
I believe that
Sqladmin
class should be parameterized withT extends AuthClient
, and then it should acceptGoogleAuth<T>
in theauth
property.Code
TypeScript Error
Type Definitions
Sqladmin:
https://github.com/googleapis/google-api-nodejs-client/blob/261170592cc5cec6a6991a356f8d6180366cb675/src/apis/sqladmin/v1beta4.ts#L54
GoogleAuth:
https://github.com/googleapis/google-auth-library-nodejs/blob/7030314c55c369acbda1873f649579b395ad07c8/src/auth/googleauth.ts#L85