gtoken

  • Version 5.3.1
  • Published
  • 36.1 kB
  • 3 dependencies
  • MIT license

Install

npm i gtoken
yarn add gtoken
pnpm add gtoken

Overview

Node.js Google Authentication Service Account Tokens

Index

Classes

class GoogleToken

class GoogleToken {}

    constructor

    constructor(options?: TokenOptions);
    • Create a GoogleToken.

      Parameter options

      Configuration object.

    property accessToken

    readonly accessToken: string;

      property additionalClaims

      additionalClaims?: {};

        property eagerRefreshThresholdMillis

        eagerRefreshThresholdMillis?: number;

          property email

          email?: string;

            property expiresAt

            expiresAt?: number;

              property idToken

              readonly idToken: string;

                property iss

                iss?: string;

                  property key

                  key?: string;

                    property keyFile

                    keyFile?: string;

                      property rawToken

                      rawToken?: TokenData;

                        property refreshToken

                        readonly refreshToken: string;

                          property scope

                          scope?: string;

                            property sub

                            sub?: string;

                              property tokenExpires

                              tokenExpires?: number;

                                property tokenType

                                readonly tokenType: string;

                                  method getCredentials

                                  getCredentials: (keyFile: string) => Promise<Credentials>;
                                  • Given a keyFile, extract the key and client email if available

                                    Parameter keyFile

                                    Path to a json, pem, or p12 file that contains the key.

                                    Returns

                                    an object with privateKey and clientEmail properties

                                  method getToken

                                  getToken: {
                                  (opts?: GetTokenOptions): Promise<TokenData>;
                                  (callback: GetTokenCallback, opts?: GetTokenOptions): void;
                                  };
                                  • Returns a cached token or retrieves a new one from Google.

                                    Parameter callback

                                    The callback function.

                                  method hasExpired

                                  hasExpired: () => boolean;
                                  • Returns whether the token has expired.

                                    true if the token has expired, false otherwise.

                                  method isTokenExpiring

                                  isTokenExpiring: () => boolean;
                                  • Returns whether the token will expire within eagerRefreshThresholdMillis

                                    true if the token will be expired within eagerRefreshThresholdMillis, false otherwise.

                                  method revokeToken

                                  revokeToken: { (): Promise<void>; (callback: (err?: Error) => void): void };
                                  • Revoke the token if one is set.

                                    Parameter callback

                                    The callback function.

                                  Interfaces

                                  interface Credentials

                                  interface Credentials {}

                                    property clientEmail

                                    clientEmail?: string;

                                      property privateKey

                                      privateKey: string;

                                        interface GetTokenOptions

                                        interface GetTokenOptions {}

                                          property forceRefresh

                                          forceRefresh?: boolean;

                                            interface TokenData

                                            interface TokenData {}

                                              property access_token

                                              access_token?: string;

                                                property expires_in

                                                expires_in?: number;

                                                  property id_token

                                                  id_token?: string;

                                                    property refresh_token

                                                    refresh_token?: string;

                                                      property token_type

                                                      token_type?: string;

                                                        interface TokenOptions

                                                        interface TokenOptions {}

                                                          property additionalClaims

                                                          additionalClaims?: {};

                                                            property eagerRefreshThresholdMillis

                                                            eagerRefreshThresholdMillis?: number;

                                                              property email

                                                              email?: string;

                                                                property iss

                                                                iss?: string;

                                                                  property key

                                                                  key?: string;

                                                                    property keyFile

                                                                    keyFile?: string;

                                                                      property scope

                                                                      scope?: string | string[];

                                                                        property sub

                                                                        sub?: string;

                                                                          Type Aliases

                                                                          type GetTokenCallback

                                                                          type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
                                                                          • Copyright 2018 Google LLC

                                                                            Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT

                                                                          Package Files (1)

                                                                          Dependencies (3)

                                                                          Dev Dependencies (10)

                                                                          Peer Dependencies (0)

                                                                          No peer dependencies.

                                                                          Badge

                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/gtoken.

                                                                          • Markdown
                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/gtoken)
                                                                          • HTML
                                                                            <a href="https://www.jsdocs.io/package/gtoken"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>