export interface Credentials { privateKey: string; clientEmail?: string; } export interface TokenData { refresh_token?: string; expires_in?: number; access_token?: string; token_type?: string; id_token?: string; } export interface TokenOptions { keyFile?: string; key?: string; email?: string; iss?: string; sub?: string; scope?: string | string[]; additionalClaims?: {}; } export declare class GoogleToken { token?: string | null; expiresAt?: number | null; key?: string; keyFile?: string; iss?: string; sub?: string; scope?: string; rawToken: TokenData | null; tokenExpires: number | null; email?: string; additionalClaims?: {}; /** * Create a GoogleToken. * * @param options Configuration object. */ constructor(options?: TokenOptions); /** * Returns whether the token has expired. * * @return true if the token has expired, false otherwise. */ hasExpired(): boolean; /** * Returns a cached token or retrieves a new one from Google. * * @param callback The callback function. */ getToken(): Promise; getToken(callback: (err: Error | null, token?: string | null | undefined) => void): void; /** * Given a keyFile, extract the key and client email if available * @param keyFile Path to a json, pem, or p12 file that contains the key. * @returns an object with privateKey and clientEmail properties */ getCredentials(keyFile: string): Promise; private getTokenAsync(); private ensureEmail(); /** * Revoke the token if one is set. * * @param callback The callback function. */ revokeToken(): Promise; revokeToken(callback: (err?: Error) => void): void; private revokeTokenAsync(); /** * Configure the GoogleToken for re-use. * @param {object} options Configuration object. */ private configure(options?); /** * Request the token from Google. */ private requestToken(); }