gtoken
- Version 7.1.0
- Published
- 41.4 kB
- 2 dependencies
- MIT license
Install
npm i gtoken
yarn add gtoken
pnpm add gtoken
Overview
Node.js Google Authentication Service Account Tokens
Index
Classes
Interfaces
Type Aliases
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;
property transporter
transporter: Transporter;
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;
property transporter
transporter?: Transporter;
interface Transporter
interface Transporter {}
method request
request: <T>(opts: GaxiosOptions) => GaxiosPromise<T>;
Type Aliases
type GetTokenCallback
type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
Package Files (1)
Dependencies (2)
Dev Dependencies (11)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 2741 ms. - Missing or incorrect documentation? Open an issue for this package.