OAuthClient overview
OAuth 2.0 Client for PingOne Token Endpoint
Provides functions for obtaining and refreshing OAuth access tokens using the client credentials grant flow.
Added in v0.0.3
Table of contents
constructors
buildTokenEndpoint
Builds the PingOne OAuth token endpoint URL for a given environment.
PingOne uses regional auth endpoints:
- North America: auth.pingone.com
- Europe: auth.pingone.eu
- Asia Pacific: auth.pingone.asia
- Canada: auth.pingone.ca
Signature
export declare const buildTokenEndpoint: (environmentId: string, region?: string) => string
Added in v0.0.3
requests
exchangeCredentialsForToken
Exchanges client credentials for an OAuth access token.
Performs the OAuth 2.0 client credentials grant flow:
- Sends client_id and client_secret to PingOne token endpoint
- Receives access_token with expiration time
- Returns token response or fails with OAuthFlowError
Signature
export declare const exchangeCredentialsForToken: (params: {
readonly clientId: string
readonly clientSecret: string
readonly tokenEndpoint: string
}) => Effect.Effect<
OAuthTokenResponse,
OAuthFlowError | HttpClientError.HttpClientError | ParseResult.ParseError,
HttpClient.HttpClient
>
Added in v0.0.3
utilities
calculateExpirationTimestamp
Calculates the expiration timestamp for an OAuth token.
Converts the expires_in value from token response to an absolute Unix timestamp for easier expiration checking.
Signature
export declare const calculateExpirationTimestamp: (expiresIn: number) => number
Added in v0.0.3
isTokenValid
Validates an OAuth access token by checking expiration.
Determines if a cached token is still valid or needs refresh. Tokens are considered expired if less than the configured buffer time remains.
Signature
export declare const isTokenValid: (expiresAt: number, bufferSeconds?: number) => boolean
Added in v0.0.3