Skip to content

parseTokenResponse

parseTokenResponse(data, expectedNonce?): TokenSet

Defined in: packages/core/src/token.ts:90

Parses and validates a raw token endpoint response into a TokenSet (RFC 6749 §5.1). Validates the nonce claim in the ID token when provided (OpenID Connect Core 1.0 §3.1.3.7). Computes expires_at as an absolute Unix timestamp when expires_in is present.

unknown

The parsed JSON body from the token endpoint response.

string

If provided, the nonce claim in the ID token must match this value.

TokenSet

A validated TokenSet with computed expires_at.

OidcError with code TOKEN_EXCHANGE_ERROR if the response is malformed or missing access_token.

OidcError with code NONCE_MISMATCH if the ID token nonce does not match.