OAuth TokensExchange or refresh OAuth tokens

Exchange or refresh OAuth tokens

Exchanges an authorization code for tokens or refreshes an existing token pair. The endpoint accepts application/x-www-form-urlencoded, application/json, or raw form-encoded payloads.

curl -X POST "https://api.example.com/mcp-server/token" \
  -H "Content-Type: application/json" \
  -d '{
  "grant_type": "authorization_code",
  "code": "mcp_code_example_1234567890abcdef",
  "redirect_uri": "https://client.example.app/callback",
  "client_id": "mcp_client_example_1234567890abcdef",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}'
{
  "access_token": "mcp_at_example_1234567890abcdef",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "mcp_rt_example_rotated_abcdef1234567890",
  "scope": "mcp"
}
POST
/token
POST
Base URLstring

Target server for requests. Edit to use your own host.

Content-Typestring
Required

The media type of the request body

Options: application/json, application/x-www-form-urlencoded, text/plain
grant_typestring
Required

OAuth grant type.

Options: authorization_code, refresh_token
codestring

Authorization code for the authorization code grant.

redirect_uristring

Redirect URI used in the original authorization request.

Format: uri
client_idstring

Registered OAuth client identifier.

code_verifierstring

PKCE code verifier, required when a code challenge was set.

refresh_tokenstring

Refresh token for the refresh token grant.

Request Preview
Response

Response will appear here after sending the request

Body

grant_typestring
Required

OAuth grant type.

Allowed values:authorization_coderefresh_token
codestring

Authorization code for the authorization code grant.

Example:
mcp_code_example_1234567890abcdef
redirect_uristring

Redirect URI used in the original authorization request.

Example:
https://client.example.app/callback
client_idstring

Registered OAuth client identifier.

Example:
mcp_client_example_1234567890abcdef
code_verifierstring

PKCE code verifier, required when a code challenge was set.

Example:
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
refresh_tokenstring

Refresh token for the refresh token grant.

Example:
mcp_rt_example_1234567890abcdef

Responses

access_tokenstring
Required

OAuth access token with a 1-hour expiry.

token_typestring
Required

Bearer token type.

Allowed values:Bearer
expires_ininteger
Required

Access token lifetime in seconds.

refresh_tokenstring
Required

Refresh token with a 30-day expiry.

scopestring
Required

Granted scope.