Token
Exchange an authorization code for tokens, or a refresh token for a new pair. Walkthrough: Sign in with Arsel.
Endpoint
POST https://api.arsel.sa/oauth/token
Returns: 200 OK
Headers
| Header | Value | Required |
|---|---|---|
Content-Type | application/x-www-form-urlencoded or application/json | Yes |
No Authorization header: clients are public, and PKCE proves the request.
Request Body: Authorization Code
| Parameter | Required | Description |
|---|---|---|
grant_type | Yes | authorization_code |
code | Yes | The code from the Authorize redirect. |
code_verifier | Yes | The PKCE verifier the code_challenge was made from: 43–128 characters of A–Z a–z 0–9 - . _ ~. |
client_id | Yes | The same client_id you sent to Authorize. |
redirect_uri | Yes | The same redirect_uri you sent to Authorize, port included. |
curl -X POST https://api.arsel.sa/oauth/token \
-d grant_type=authorization_code \
-d code="$CODE" \
-d code_verifier="$CODE_VERIFIER" \
-d client_id=https://app.example.com/oauth/client.json \
-d redirect_uri=https://app.example.com/oauth/callback
A code works once and expires 10 minutes after the user approves.
Request Body: Refresh Token
| Parameter | Required | Description |
|---|---|---|
grant_type | Yes | refresh_token |
refresh_token | Yes | The latest refresh token for this connection. |
client_id | Recommended | Your client_id. If sent, it must match the connection's. |
curl -X POST https://api.arsel.sa/oauth/token \
-d grant_type=refresh_token \
-d refresh_token="$REFRESH_TOKEN" \
-d client_id=https://app.example.com/oauth/client.json
Each refresh returns a new refresh token and retires the one you sent. Replaying a retired token within 60 seconds is refused; after 60 seconds it revokes the connection. See Refresh tokens.
Neither grant needs resource. If you send it, it must be the MCP server's URL.
Response
{
"access_token": "eyJhbGciOiJFUzI1NiIs…",
"token_type": "Bearer",
"expires_in": 900,
"refresh_token": "arsel_rt_…",
"scope": "full_access"
}
| Field | Type | Description |
|---|---|---|
access_token | string | Send as Authorization: Bearer <access_token> to https://api.arsel.sa/v1. Treat it as opaque. |
token_type | string | Always Bearer |
expires_in | number | Seconds until the access token expires: 900 (15 minutes) |
refresh_token | string | Replaces any earlier refresh token for this connection. Valid for 60 days, renewed on every refresh. |
scope | string | The granted scopes: full_access |
Rate Limit
600 requests per minute per IP address. Revoke has its own, separate limit. Above it the endpoint returns 429.
Error Responses
Errors use the OAuth format, not the Arsel API error format.
- 400 Invalid Grant
- 400 Invalid Request
- 400 Unsupported Grant Type
- 400 Invalid Target
The code is wrong, expired or already used, or client_id, redirect_uri or code_verifier doesn't match the authorization request:
{
"error": "invalid_grant",
"error_description": "The authorization code is invalid, expired or already used"
}
The refresh token is wrong, expired, already used or revoked, or the connection has ended:
{
"error": "invalid_grant",
"error_description": "The refresh token is invalid, expired or revoked"
}
{
"error": "invalid_request",
"error_description": "code and code_verifier are required"
}
{
"error": "unsupported_grant_type",
"error_description": "Supported grant types: authorization_code, refresh_token"
}
{
"error": "invalid_target",
"error_description": "resource must be https://mcp.arsel.sa"
}