Getting started
Read this page as MarkdownIn this section: OAuth app
OAuth app
Use OAuth 2.1 to call Miles on another user's behalf with their consent.
Before you start
There is no app dashboard. Registration is Dynamic Client Registration (RFC 7591) against the MCP server's issuer, one request per client. Register with token_endpoint_auth_method: "none", as below, and the client is public: no client secret is issued, and PKCE protects the code exchange. Leaving it out registers a client_secret_post client. With client_secret_post or client_secret_basic, the response also carries a client_secret that the token endpoint then requires. What you register is what you get back; there is no console to edit it later, so re-register if a redirect URI changes.
Every token belongs to the Miles user who approved it. Miles never sees a password; consent happens on askmiles.ai where the user's session already is.
1. Discover the issuer
Fetch the authorization server metadata once and read the endpoints from it. Do not hardcode them.
curl https://mcp.askmiles.ai/.well-known/oauth-authorization-serverThe document names registration_endpoint, authorization_endpoint, token_endpoint, revocation_endpoint, the supported scopes, and S256 as the only PKCE method.
2. Register the client
curl https://mcp.askmiles.ai/register \
-H "Content-Type: application/json" \
-d '{
"client_name": "Trip planner",
"redirect_uris": ["https://example.com/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "none",
"scope": "miles:read miles:chat"
}'The response repeats what you sent plus a client_id (and a client_secret if you registered a confidential client). Keep them.
Redirect URIs must be https, except loopback http://127.0.0.1 and http://localhost for a native or command-line client. At most ten per client. client_name is what the consent screen shows, cut at 40 characters; a logo URI is ignored.
The registration, token and revocation endpoints share one per-IP limit of 20 requests a minute, and the registration body is capped. Register once and store the result.
3. Send the user to authorize
Generate a PKCE verifier and its S256 challenge. Then open the authorization URL.
https://mcp.askmiles.ai/authorize
?response_type=code
&client_id=CLIENT_ID
&redirect_uri=https://example.com/oauth/callback
&scope=miles:read%20miles:chat
&code_challenge=CHALLENGE
&code_challenge_method=S256
&state=RANDOM
&resource=https://mcp.askmiles.ai/mcpThe consent page at askmiles.ai lists exactly what your app can access. Read access is on. miles:write has a separate toggle and stays off unless the user turns it on. A token never carries miles:write unless the user turns it on. After approval, the browser returns code and state to your redirect URI.
resource (RFC 8707) names the server the token is for. Leave it at the MCP server URL. A request naming a different resource keeps only the scopes that server serves, and a request that keeps none is refused with invalid_scope. There is no fallback to miles:read.
4. Exchange the code
curl https://mcp.askmiles.ai/token \
-d grant_type=authorization_code \
-d client_id=CLIENT_ID \
-d code=CODE \
-d redirect_uri=https://example.com/oauth/callback \
-d code_verifier=VERIFIER{
"access_token": "miles_at_…",
"refresh_token": "miles_rt_…",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "miles:read miles:chat"
}Access tokens live one hour. Refresh tokens live thirty days and rotate: each refresh returns a new pair and retires the old refresh token. Every token is prefixed (miles_at_, miles_rt_, miles_ac_ for a code) so a leak is recognizable in a log.
5. Call Miles
Connect to the MCP server and call tools with miles:read or miles:write. See the MCP overview. Call the Chat API with miles:chat, as you would with a personal key.
curl https://askmiles.ai/v1/chat/completions \
-H "Authorization: Bearer miles_at_…" \
-H "Content-Type: application/json" \
-d '{"model": "miles", "messages": [{"role": "user", "content": "Which of my cards earns most on dining?"}]}'6. Refresh and revoke
curl https://mcp.askmiles.ai/token \
-d grant_type=refresh_token \
-d client_id=CLIENT_ID \
-d refresh_token=miles_rt_…To revoke a grant, post its token to the revocation endpoint. The user can end the grant anytime in Settings → Connected AI Apps. That screen shows client_name and a Disconnect control. A paused account keeps its tokens and refuses every call until the user resumes: MCP tool calls with paused, Chat API calls with connections_paused.
Scopes you can request
| Scope | What it reaches | Default |
|---|---|---|
miles:read | Every read tool on the MCP server | Requested when you send no scope |
miles:write | The twenty-three write tools; eleven also need the user to be a Member | Off until the user toggles it on |
miles:write:reconcile | Just the reconciliation-loop writes (set_credit_usage, clear_credit_usage, set_free_night_status, set_certificate_status, set_status_entitlement, undo_status_entitlement, set_balances, undo_balance_write, set_cap_status and clear_cap_status): a narrower grant a user can choose at consent. miles:write already covers it. A client cannot register for it or request it | Off until the user toggles it on |
miles:chat | /v1/chat/completions and /v1/models | Off |
Other scopes exist for Miles' own apps and are refused to a registered client.