diff --git a/src/auth/authclient.ts b/src/auth/authclient.ts index 8e004d63..69301db8 100644 --- a/src/auth/authclient.ts +++ b/src/auth/authclient.ts @@ -207,6 +207,26 @@ export abstract class AuthClient this.forceRefreshOnFailure = opts.forceRefreshOnFailure ?? false; } + /** + * Return the {@link Gaxios `Gaxios`} instance from the {@link AuthClient.transporter}. + * + * @expiremental + */ + get gaxios(): Gaxios | null { + if (this.transporter instanceof Gaxios) { + return this.transporter; + } else if (this.transporter instanceof DefaultTransporter) { + return this.transporter.instance; + } else if ( + 'instance' in this.transporter && + this.transporter.instance instanceof Gaxios + ) { + return this.transporter.instance; + } + + return null; + } + /** * Provides an alternative Gaxios request implementation with auth credentials */ diff --git a/src/index.ts b/src/index.ts index 77ad950a..1ab32948 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,10 @@ // limitations under the License. import {GoogleAuth} from './auth/googleauth'; +// Export common deps to ensure types/instances are the exact match. Useful +// for consistently configuring the library across versions. export * as gcpMetadata from 'gcp-metadata'; +export * as gaxios from 'gaxios'; export {AuthClient, DEFAULT_UNIVERSE} from './auth/authclient'; export {Compute, ComputeOptions} from './auth/computeclient';