Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClientCredentialsOAuthClient

Client Credential OAuth Client

Will automatically process the token refresh logic

refresh policy: half expire-in

example
// please remember share client instance for a same OAuth server
const client = new ClientCredentialsOAuthClient(
 "http://example/oauth/token",
 "client_id",
 "client_secret"
)
const response = await client.axios({
 method: "GET",
 url: "http://protected.by.jwt/resource"
})

Hierarchy

  • ClientCredentialsOAuthClient

Index

Constructors

constructor

  • Parameters

    • tokenUrl: string

      oauth token url

    • clientId: string

      oauth client id

    • clientSecret: string

      oauth client secret

    Returns ClientCredentialsOAuthClient

Properties

Private clientId

clientId: string

Private clientSecret

clientSecret: string

Private jobId

jobId: any

Private mut

mut: Mutex

Private token

token: string

Private tokenUrl

tokenUrl: string

Methods

destroy

  • destroy(): void
  • destroy this client

    Returns void

fetch

  • fetch(...args: [input: RequestInfo, init?: RequestInit]): Promise<Response>
  • send axios request with oauth token

    Parameters

    • Rest ...args: [input: RequestInfo, init?: RequestInit]

    Returns Promise<Response>

Private fetchOAuthResponse

  • fetchOAuthResponse(): Promise<any>
  • fetch token directly

    Returns Promise<any>

getHeader

  • getHeader(): Promise<{ Authorization: string }>
  • get header pair

    Returns Promise<{ Authorization: string }>

getToken

  • getToken(): Promise<string>
  • get current valid oauth token

    Returns Promise<string>

Generated using TypeDoc