Skip to main content

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​

HeaderValueRequired
Content-Typeapplication/x-www-form-urlencoded or application/jsonYes

No Authorization header: clients are public, and PKCE proves the request.

Request Body: Authorization Code​

ParameterRequiredDescription
grant_typeYesauthorization_code
codeYesThe code from the Authorize redirect.
code_verifierYesThe PKCE verifier the code_challenge was made from: 43–128 characters of A–Z a–z 0–9 - . _ ~.
client_idYesThe same client_id you sent to Authorize.
redirect_uriYesThe 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​

ParameterRequiredDescription
grant_typeYesrefresh_token
refresh_tokenYesThe latest refresh token for this connection.
client_idRecommendedYour 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"
}
FieldTypeDescription
access_tokenstringSend as Authorization: Bearer <access_token> to https://api.arsel.sa/v1. Treat it as opaque.
token_typestringAlways Bearer
expires_innumberSeconds until the access token expires: 900 (15 minutes)
refresh_tokenstringReplaces any earlier refresh token for this connection. Valid for 60 days, renewed on every refresh.
scopestringThe 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.

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"
}