Skip to content

spotify-cli


spotify-cli / auth/pkce

auth/pkce ​

PKCE (Proof Key for Code Exchange) helpers for the OAuth 2.0 flow.

Generates the code verifier, code challenge, and state values used during the Spotify authorization code flow with PKCE.

See ​

RFC 7636 — PKCE

Functions ​

generateCodeChallenge() ​

generateCodeChallenge(verifier): Promise<string>

Defined in: src/auth/pkce.ts:25

Derives a SHA-256 code challenge from a code verifier.

Parameters ​

verifier ​

string

The code verifier string to hash.

Returns ​

Promise<string>

A base64url-encoded SHA-256 hash of the verifier.


generateCodeVerifier() ​

generateCodeVerifier(): string

Defined in: src/auth/pkce.ts:15

Generates a cryptographically random code verifier (64 bytes, base64url-encoded).

Returns ​

string

A base64url-encoded random string suitable for use as a PKCE code verifier.


generateState() ​

generateState(): string

Defined in: src/auth/pkce.ts:36

Generates a cryptographically random state string for CSRF protection.

Returns ​

string

A base64url-encoded random string (16 bytes).

MIT Licensed. Not affiliated with or endorsed by Spotify AB.