Class GoogleToken (5.3.2)

Package

gtoken

Constructors

(constructor)(options)

  constructor 
 ( 
 options 
 ?: 
  
 TokenOptions 
 ); 
 

Create a GoogleToken.

Parameter
Name Description
options TokenOptions

Configuration object.

Properties

accessToken

  get 
  
 accessToken 
 () 
 : 
  
 string 
  
 | 
  
 undefined 
 ; 
 

additionalClaims

  additionalClaims 
 ?: 
  
 {}; 
 

eagerRefreshThresholdMillis

  eagerRefreshThresholdMillis 
 ?: 
  
 number 
 ; 
 

email

  email 
 ?: 
  
 string 
 ; 
 

expiresAt

  expiresAt 
 ?: 
  
 number 
 ; 
 

idToken

  get 
  
 idToken 
 () 
 : 
  
 string 
  
 | 
  
 undefined 
 ; 
 

iss

  iss 
 ?: 
  
 string 
 ; 
 

key

  key 
 ?: 
  
 string 
 ; 
 

keyFile

  keyFile 
 ?: 
  
 string 
 ; 
 

rawToken

  rawToken 
 ?: 
  
 TokenData 
 ; 
 

refreshToken

  get 
  
 refreshToken 
 () 
 : 
  
 string 
  
 | 
  
 undefined 
 ; 
 

scope

  scope 
 ?: 
  
 string 
 ; 
 

sub

  sub 
 ?: 
  
 string 
 ; 
 

tokenExpires

  tokenExpires 
 ?: 
  
 number 
 ; 
 

tokenType

  get 
  
 tokenType 
 () 
 : 
  
 string 
  
 | 
  
 undefined 
 ; 
 

Methods

getCredentials(keyFile)

  getCredentials 
 ( 
 keyFile 
 : 
  
 string 
 ) 
 : 
  
 Promise<Credentials> 
 ; 
 

Given a keyFile, extract the key and client email if available

Parameter
Name Description
keyFile string

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

Returns
Type Description
Promise < Credentials >

an object with privateKey and clientEmail properties

getToken(opts)

  getToken 
 ( 
 opts 
 ?: 
  
 GetTokenOptions 
 ) 
 : 
  
 Promise<TokenData> 
 ; 
 

Returns a cached token or retrieves a new one from Google.

Parameter
Name Description
opts GetTokenOptions
Returns
Type Description
Promise < TokenData >

getToken(callback, opts)

  getToken 
 ( 
 callback 
 : 
  
 GetTokenCallback 
 , 
  
 opts 
 ?: 
  
 GetTokenOptions 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
callback GetTokenCallback
opts GetTokenOptions
Returns
Type Description
void

hasExpired()

  hasExpired 
 () 
 : 
  
 boolean 
 ; 
 

Returns whether the token has expired.

true if the token has expired, false otherwise.

Returns
Type Description
boolean

isTokenExpiring()

  isTokenExpiring 
 () 
 : 
  
 boolean 
 ; 
 

Returns whether the token will expire within eagerRefreshThresholdMillis

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

Returns
Type Description
boolean

revokeToken()

  revokeToken 
 () 
 : 
  
 Promise<void> 
 ; 
 

Revoke the token if one is set.

Returns
Type Description
Promise <void>

revokeToken(callback)

  revokeToken 
 ( 
 callback 
 : 
  
 ( 
 err 
 ?: 
  
 Error 
 ) 
  
 = 
>  
 void 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback (err?: Error ) => void
Returns
Type Description
void
Design a Mobile Site
View Site in Mobile | Classic
Share by: