music nerd

MCP OAuthGet a token

MCP OAuth

Get a token

Swaps an authorization code or a refresh token for a new access token and refresh token. Access tokens last five minutes. Refresh tokens rotate on every use and last until the user disconnects the agent; reusing one that was already used disconnects the agent, if it is the last one used or was used in the past 30 days.

POST/api/oauth/token
POST/api/oauth/token

Swaps an authorization code or a refresh token for a new access token and refresh token. Access tokens last five minutes. Refresh tokens rotate on every use and last until the user disconnects the agent; reusing one that was already used disconnects the agent, if it is the last one used or was used in the past 30 days.

Body
cURL
curl --request POST \
  --url 'https://musicnerd-api.vercel.app/api/oauth/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data '{
  "grant_type": "authorization_code",
  "client_id": "2f6c1d0e-8a4b-4c47-9a51-3e0f7b9d2c18",
  "code": "mn_code_EXAMPLE",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
  "redirect_uri": "http://127.0.0.1:33418/callback"
}'

Send the request to see the live response here.

Authorizations

None. This endpoint is public.

Body

application/x-www-form-urlencodedrequired
grant_typestring · enumrequired

Values: "authorization_code", "refresh_token"

client_idstringrequired

The client_id from registration.

codestring

For authorization_code: the code from the redirect. Single use, valid for 60 seconds.

code_verifierstring

For authorization_code: the PKCE verifier behind code_challenge.

redirect_uristring

For authorization_code: the same redirect_uri as the authorization request.

refresh_tokenstring

For refresh_token: the latest refresh token. Single use.

Response

application/json

A new access token and refresh token, with Cache-Control: no-store.

access_tokenstringrequired

Send as Authorization: Bearer to /mcp.

token_typestring · enumrequired

Values: "Bearer"

expires_inintegerrequired

Seconds until the access token expires: 300.

refresh_tokenstringrequired

Single use; the next refresh returns a new one.

scopestringrequired