Skip to content

spotify-cli


spotify-cli / auth/server

auth/server

Local HTTP callback server for the OAuth authorization flow.

Starts a temporary HTTP server on CALLBACK_PORT that waits for Spotify to redirect the user back with an authorization code. The server automatically shuts down after receiving the callback or timing out.

Functions

startCallbackServer()

startCallbackServer(expectedState): Promise<CallbackResult>

Defined in: src/auth/server.ts:32

Starts a local HTTP server and waits for the OAuth callback.

The server validates the state parameter against expectedState to prevent CSRF attacks. It times out after 120 seconds.

Parameters

expectedState

string

The state value sent in the authorization request.

Returns

Promise<CallbackResult>

The authorization code and state from the callback.

Throws

SpotifyCliError on timeout, missing parameters, or state mismatch.

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