Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

  • new JWT(options: JWTOptions): JWT
  • new JWT(email?: string, keyFile?: string, key?: string, scopes?: string | string[], subject?: string, keyId?: string): JWT
  • JWT service account credentials.

    Retrieve access token using gtoken.

    Parameters

    Returns JWT

  • Parameters

    • Optional email: string
    • Optional keyFile: string
    • Optional key: string
    • Optional scopes: string | string[]
    • Optional subject: string
    • Optional keyId: string

    Returns JWT

Properties

_clientId?: string
_clientSecret?: string
additionalClaims?: {}

Type declaration

    apiKey?: string
    credentials: Credentials
    defaultScopes?: string | string[]
    defaultServicePath?: string
    eagerRefreshThresholdMillis: number
    email?: string
    forceRefreshOnFailure: boolean
    gtoken?: GoogleToken
    key?: string
    keyFile?: string
    keyId?: string
    projectId?: null | string
    quotaProjectId?: string

    The quota project ID. The quota project can be used by client libraries for the billing purpose. See Working with quotas

    refreshHandler?: GetRefreshHandlerCallback
    scope?: string
    scopes?: string | string[]
    subject?: string
    transporter: Transporter
    universeDomain: string
    useJWTAccessWithScope?: boolean

    Methods

    • Get the initial access token using gToken.

      Returns Promise<Credentials>

      Promise that resolves with credentials

    • Parameters

      • callback: (err: null | Error, result?: Credentials) => void
          • Parameters

            Returns void

      Returns void

    • createScoped(scopes?: string | string[]): JWT
    • Creates a copy of the credential with the specified scopes.

      Parameters

      • Optional scopes: string | string[]

        List of requested scopes or a single scope.

      Returns JWT

      The cloned instance.

    • fetchIdToken(targetAudience: string): Promise<string>
    • Fetches an ID token.

      Parameters

      • targetAudience: string

        the audience for the fetched ID token.

      Returns Promise<string>

    • fromAPIKey(apiKey: string): void
    • Creates a JWT credentials instance using an API Key for authentication.

      Parameters

      • apiKey: string

        The API Key in string form.

      Returns void

    • Create a JWT credentials instance using the given input options.

      Parameters

      Returns void

    • fromStream(inputStream: Readable): Promise<void>
    • fromStream(inputStream: Readable, callback: (err?: null | Error) => void): void
    • Create a JWT credentials instance using the given input stream.

      Parameters

      • inputStream: Readable

        The input stream.

      Returns Promise<void>

    • Parameters

      • inputStream: Readable
      • callback: (err?: null | Error) => void
          • (err?: null | Error): void
          • Parameters

            • Optional err: null | Error

            Returns void

      Returns void

    • Generates URL for consent page landing.

      Parameters

      Returns string

      URL to consent page.

    • generateCodeVerifier(): void
    • Using the key or keyFile on the JWT client, obtain an object that contains the key and the client email.

      Returns Promise<CredentialBody>

    • Gets federated sign-on certificates to use for verifying identity tokens. Returns certs as array structure, where keys are key ids, and values are certificates in either PEM or JWK format.

      Returns Promise<IapPublicKeysResponse>

    • Parameters

      Returns void

    • getRequestHeaders(url?: string): Promise<Headers>
    • The main authentication interface. It takes an optional url which when present is the endpoint being accessed, and returns a Promise which resolves with authorization header fields.

      In OAuth2Client, the result has the form: { Authorization: 'Bearer ' }

      Parameters

      • Optional url: string

        The optional url being authorized

      Returns Promise<Headers>

    • getTokenInfo(accessToken: string): Promise<TokenInfo>
    • Obtains information about the provisioned access token. Especially useful if you want to check the scopes that were provisioned to a given token.

      Parameters

      • accessToken: string

        Required. The Access Token for which you want to get user info.

      Returns Promise<TokenInfo>

    • Subscribes a listener to the tokens event triggered when a token is generated.

      Parameters

      Returns JWT

    • Provides a request implementation with OAuth 2.0 flow. If credentials have a refresh_token, in cases of HTTP 401 and 403 responses, it automatically asks for a new access token and replays the unsuccessful request.

      Type parameters

      • T

      Parameters

      Returns GaxiosPromise<T>

      Request object

    • Type parameters

      • T

      Parameters

      Returns void

    • Sets the auth credentials.

      Parameters

      Returns void

    • verifySignedJwtWithCerts(): void
    • verifySignedJwtWithCertsAsync(jwt: string, certs: Certificates | PublicKeys, requiredAudience?: string | string[], issuers?: string[], maxExpiry?: number): Promise<LoginTicket>
    • Verify the id token is signed with the correct certificate and is from the correct audience.

      Parameters

      • jwt: string

        The jwt to verify (The ID Token in this case).

      • certs: Certificates | PublicKeys

        The array of certs to test the jwt against.

      • Optional requiredAudience: string | string[]

        The audience to test the jwt against.

      • Optional issuers: string[]

        The allowed issuers of the jwt (Optional).

      • Optional maxExpiry: number

        The max expiry the certificate can be (Optional).

      Returns Promise<LoginTicket>

      Returns a promise resolving to LoginTicket on verification.

    • getRevokeTokenUrl(token: string): string
    • Generates an URL to revoke the given token.

      Parameters

      • token: string

        The existing token to be revoked.

      Returns string