Class: Token
Internal representation of a OAuth2/OIDC Token.
Contains accessToken, conditionally contains idToken and refreshToken
Remarks
Most operations can be done by Credential methods. It's recommended to use those instead before reaching for a Token method
See
- Okta Documentation: OIDC
Extends
TokenImpl
Implements
Constructors
new Token()
new Token(
obj):Token
The constructor of Token
Parameters
• obj: TokenJSON
Returns
Inherited from
TokenImpl.constructor
Properties
id
readonlyid:string
Inherited from
TokenImpl.id
issuedAt
readonlyissuedAt:Date
Implementation of
Inherited from
TokenImpl.issuedAt
tokenType
readonlytokenType:TokenType
The audience of the token. ex Bearer or DPoP
Inherited from
TokenImpl.tokenType
expiresIn
readonlyexpiresIn:number
Seconds until token expires
Implementation of
Inherited from
TokenImpl.expiresIn
scope
readonlyscope:undefined|string
OAuth2 / OIDC scopes associated with token
Inherited from
TokenImpl.scope
accessToken
readonlyaccessToken:string
String value of accessToken
Inherited from
TokenImpl.accessToken
idToken?
readonlyoptionalidToken:JWT
If the OAuth2 configuration includes OIDC, an idToken will be available
Inherited from
TokenImpl.idToken
refreshToken?
readonlyoptionalrefreshToken:string
If the OAuth2 configuration includes the scope offline_access, a refreshToken will be available
Inherited from
TokenImpl.refreshToken
context
readonlycontext:Context
Defines the context this token was issued from
Inherited from
TokenImpl.context
Accessors
expiresAt
getexpiresAt():Date
When the Token will expire, represented as a Date
Returns
Date
Implementation of
Inherited from
TokenImpl.expiresAt
isExpired
getisExpired():boolean
Compares this.expiresAt against TimeCoordinator to determine if Token is expired
Returns
boolean
Implementation of
Inherited from
TokenImpl.isExpired
isValid
getisValid():boolean
Returns true if the Token is not expired
See
Returns
boolean
Implementation of
Inherited from
TokenImpl.isValid
scopes
getscopes():string[]
Returns the OAuth2 scope(s) used to issue the token
Returns
string[]
Inherited from
TokenImpl.scopes
Methods
serializer()
staticserializer(t):string
Parameters
• t: object
Returns
string
Inherited from
TokenImpl.serializer
isEqual()
staticisEqual(lhs,rhs):boolean
Parameters
• lhs: Token
• rhs: Token
Returns
boolean
Inherited from
TokenImpl.isEqual
decode()
staticdecode<T>(encoded):T
Type Parameters
• T
Parameters
• encoded: string
Returns
T
Inherited from
TokenImpl.decode
merge()
merge(
token):Token
Used to merge separate Token instances together. Useful when handling token refresh as not every value is returned in a refresh request compared to the initial token request
Parameters
• token: Token
the "old" token instance to be merged into the "new" token
Returns
new Token instance
Inherited from
TokenImpl.merge
serialize()
serialize():
string
Returns
string
Inherited from
TokenImpl.serialize
authorize()
authorize(
input,init?):Promise<Request>
Signs a outgoing Request with an Authorization header.
Accepts the same method signature as fetch
Parameters
• input: string | URL | Request
• init?: RequestInit
Returns
Promise<Request>
Request wrapped in a Promise
TODO: add dpop support (method is async for this purpose)
Inherited from
TokenImpl.authorize
toJSON()
toJSON()
toJSON():
Record<string,unknown>
Returns
Record<string, unknown>
Inherited from
TokenImpl.toJSON
toJSON()
toJSON():
TokenJSON
Converts a Token instance to an serializable object literal representation
Returns
Inherited from
TokenImpl.toJSON
encode()
encode():
string
Returns
string
Implementation of
Codable.encode
Inherited from
TokenImpl.encode