Home Manual Reference Source
public class | source

OAuthToken

Oauth token container

Static Member Summary

Static Public Members
public static get

Internal storage key name

Static Method Summary

Static Public Methods
public static

Build instance from response object

public static

Recover a token by looking through the HTTPS cookies and localStorage

Constructor Summary

Public Constructor
public

constructor(token: String, type: String, expires: Date | Number, scopes: Array<string>)

Member Summary

Public Members
public get

If the token has expired

public

expires: *

public

scopes: *

public

token: *

public

type: *

Method Summary

Public Methods
public

save(name: String)

Store the token for later recovery.

public

Export oauth response query string

public

toResponseObject(): {access_token: String|*, token_type: String, expires_in: Number, scope: Array<String>|Array|*}

Get equivalent OAuth response object

public

String representation of the token, usable in the Authorization header

Static Public Members

public static get storageName: String: string source

Internal storage key name

Return:

String

storage name

Static Public Methods

public static fromResponseObject(data: String | Object): OAuthToken source

Build instance from response object

Params:

NameTypeAttributeDescription
data String | Object

object or JSON string

Return:

OAuthToken

New OAuthToken instance

public static recover(name: String): OAuthToken | null source

Recover a token by looking through the HTTPS cookies and localStorage

Params:

NameTypeAttributeDescription
name String

Storage key name

Return:

OAuthToken | null

null if none could be recovered

Throw:

save

Public Constructors

public constructor(token: String, type: String, expires: Date | Number, scopes: Array<string>) source

Params:

NameTypeAttributeDescription
token String

OAuth token

type String
  • optional
  • default: Bearer

token type

expires Date | Number
  • optional
  • default: 5 days

expire time in seconds or Date

scopes Array<string>
  • optional
  • default: []

Any scopes

Public Members

public get expired: Boolean: * source

If the token has expired

Return:

Boolean

expired

public expires: * source

public scopes: * source

public token: * source

public type: * source

Public Methods

public save(name: String) source

Store the token for later recovery. Token will be stored in HTTPS cookie if possible.

Params:

NameTypeAttributeDescription
name String

db key name

Throw:

OAuthToken#recover

public toQueryString(): string source

Export oauth response query string

Return:

string

OAuth response query

public toResponseObject(): {access_token: String|*, token_type: String, expires_in: Number, scope: Array<String>|Array|*} source

Get equivalent OAuth response object

Return:

{access_token: String|*, token_type: String, expires_in: Number, scope: Array<String>|Array|*}

Raw response object

public toString(): string source

String representation of the token, usable in the Authorization header

Return:

string

String representation