Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

Hierarchy

  • GoogleAuth

Index

Constructors

Properties

cachedCredential: null | JSONClient | T | Compute
defaultScopes?: string | string[]

Scopes populated by the client library by default. We differentiate between these and user defined scopes when deciding whether to use a self-signed JWT.

defaultServicePath?: string
transporter?: Transporter
useJWTAccessWithScope?: boolean
DefaultTransporter: typeof DefaultTransporter

Export DefaultTransporter as a static property of the class.

Accessors

  • get isGCE(): undefined | boolean
  • Returns undefined | boolean

Methods

  • _checkIsGCE(): Promise<boolean>
  • Determines whether the auth layer is running on Google Compute Engine. Checks for GCP Residency, then fallback to checking if metadata server is available.

    api

    private

    Returns Promise<boolean>

    A promise that resolves with the boolean.

  • Attempts to load default credentials from a file at the given path..

    api

    private

    Parameters

    Returns Promise<JSONClient>

    Promise that resolves with the OAuth2Client

  • Attempts to load default credentials from the environment variable path..

    api

    private

    Parameters

    Returns Promise<null | JSONClient>

    Promise that resolves with the OAuth2Client or null.

  • Attempts to load default credentials from a well-known file location

    api

    private

    Parameters

    Returns Promise<null | JSONClient>

    Promise that resolves with the OAuth2Client or null.

  • authorizeRequest(opts: { headers?: Headers; uri?: string; url?: string }): Promise<{ headers?: Headers; uri?: string; url?: string }>
  • Obtain credentials for a request, then attach the appropriate headers to the request options.

    Parameters

    • opts: { headers?: Headers; uri?: string; url?: string }

      Axios or Request options on which to attach the headers

      • Optional headers?: Headers
      • Optional uri?: string
      • Optional url?: string

    Returns Promise<{ headers?: Headers; uri?: string; url?: string }>

  • Create a credentials instance using the given API key string.

    Parameters

    • apiKey: string

      The API key string

    • Optional options: AuthClientOptions

      An optional options object.

    Returns JWT

    A JWT loaded from the key

  • Create a credentials instance using a given impersonated input options.

    Parameters

    Returns Impersonated

    JWT or UserRefresh Client with data

  • Create a credentials instance using the given input options.

    Parameters

    Returns JSONClient

    JWT or UserRefresh Client with data

  • Create a credentials instance using the given input stream.

    Parameters

    • inputStream: Readable

      The input stream.

    Returns Promise<JSONClient>

  • Parameters

    Returns void

  • Parameters

    Returns Promise<JSONClient>

  • Parameters

    Returns void

  • getAccessToken(): Promise<undefined | null | string>
  • Automatically obtain application default credentials, and return an access token for making requests.

    Returns Promise<undefined | null | string>

  • Obtains the default service-level credentials for the application.

    Returns Promise<ADCResponse>

    Promise that resolves with the ADCResponse (if no callback was passed).

  • Parameters

    Returns void

  • Parameters

    Returns Promise<ADCResponse>

  • Parameters

    Returns void

  • Automatically obtain an AuthClient based on the provided configuration. If no options were passed, use Application Default Credentials.

    Returns Promise<JSONClient | T | Compute>

  • The callback function handles a credential object that contains the client_email and private_key (if exists). getCredentials first checks if the client is using an external account and uses the service account email in place of client_email. If that doesn't exist, it checks for these values from the user JSON. If the user JSON doesn't exist, and the environment is on GCE, it gets the client_email from the cloud metadata server.

    Returns Promise<CredentialBody>

  • Parameters

    Returns void

  • Determine the compute environment in which the code is running.

    Returns Promise<GCPEnv>

  • Creates a client which will fetch an ID token for authorization.

    Parameters

    • targetAudience: string

      the audience for the fetched ID token.

    Returns Promise<IdTokenClient>

    IdTokenClient for making HTTP calls authenticated with ID tokens.

  • Obtains the default project ID for the application.

    Retrieves in the following order of precedence:

    • The projectId provided in this object's construction
    • GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable
    • GOOGLE_APPLICATION_CREDENTIALS JSON file
    • Cloud SDK: gcloud config config-helper --format json
    • GCE project ID from metadata server

    Returns Promise<string>

  • Parameters

    Returns void

  • getRequestHeaders(url?: string): Promise<Headers>
  • Obtain the HTTP headers that will provide authorization for a given request.

    Parameters

    • Optional url: string

    Returns Promise<Headers>

  • Automatically obtain application default credentials, and make an HTTP request using the given options.

    Type parameters

    • T = any

    Parameters

    Returns Promise<GaxiosResponse<T>>

  • setGapicJWTValues(client: JWT): void
  • Parameters

    Returns void

  • sign(data: string): Promise<string>
  • Sign the given data with the current private key, or go out to the IAM API to sign it.

    Parameters

    • data: string

      The data to be signed.

    Returns Promise<string>