Skip to main content Link Search Menu Expand Document (external link)

OAuthSchemas overview

OAuth 2.0 Client Credentials Flow Schemas

Defines schemas for OAuth token endpoint requests and responses. Used for type-safe OAuth client credentials grant flow with PingOne.

Added in v0.0.3


Table of contents


models

CachedAccessToken (class)

Cached Access Token Schema

Schema for cached access tokens with expiration tracking. Used to avoid unnecessary token refresh requests.

Signature

export declare class CachedAccessToken

Example

import { DateTime } from "effect"
import { Schema } from "effect"

const now = DateTime.unsafeNow()
const cachedToken = {
  accessToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  expiresAt: DateTime.toEpochMillis(DateTime.add(now, { hours: 1 }))
}

const validated = Schema.decodeUnknownSync(CachedAccessToken)(cachedToken)

Added in v0.0.3

OAuthErrorResponse (class)

OAuth 2.0 Error Response Schema

Schema for error responses from OAuth token endpoint. Follows RFC 6749 OAuth 2.0 error response format.

Signature

export declare class OAuthErrorResponse

Example

import { Schema } from "effect"

const errorResponse = {
  error: "invalid_client",
  error_description: "Client authentication failed"
}

const validated = Schema.decodeUnknownSync(OAuthErrorResponse)(errorResponse)

Added in v0.0.3

OAuthTokenRequest (class)

OAuth 2.0 Token Request Schema

Schema for client credentials grant token request. Sent as application/x-www-form-urlencoded to PingOne token endpoint.

Signature

export declare class OAuthTokenRequest

Example

import { Schema } from "effect"

const request = {
  grant_type: "client_credentials",
  client_id: "abc123-client-id",
  client_secret: "xyz789-client-secret"
}

const validated = Schema.decodeUnknownSync(OAuthTokenRequest)(request)

Added in v0.0.3

OAuthTokenResponse (class)

OAuth 2.0 Token Response Schema

Schema for successful token response from PingOne. Contains access token, type, and expiration information.

Signature

export declare class OAuthTokenResponse

Example

import { Schema } from "effect"

const response = {
  access_token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  token_type: "Bearer",
  expires_in: 3600
}

const validated = Schema.decodeUnknownSync(OAuthTokenResponse)(response)

Added in v0.0.3

StoredCredentials (class)

Stored OAuth Credentials Schema

Schema for credentials stored in keychain or encrypted file. Contains client credentials and environment information.

Signature

export declare class StoredCredentials

Example

import { Schema } from "effect"

const storedCreds = {
  clientId: "abc123",
  clientSecret: "xyz789",
  environmentId: "env-456",
  tokenEndpoint: "https://auth.pingone.com/env-456/as/token"
}

const validated = Schema.decodeUnknownSync(StoredCredentials)(storedCreds)

Added in v0.0.3