# OAuth sign-in · how it works

OAuth 2.1 for public clients: authorization code with PKCE S256, no client secret, consent on Xale's own page, opaque bearer tokens.

Checked 2026-12-04 · https://xale.app/docs/ai/oauth-sign-in-how-it-works

## The shape

- OAuth 2.1, public clients only: no client secret, `token_endpoint_auth_methods_supported: ["none"]`.
- Authorization code with PKCE; `S256` is required.
- Clients register themselves (RFC 7591), but only with the known apps' callback addresses or a loopback address. See [Dynamic client registration](https://xale.app/docs/ai/dynamic-client-registration-details).
- The person approves on Xale's own page, signed in to their Xale account.

## Discovery

A call to `/api/mcp` without a valid token gets `401`, JSON-RPC code `-32001` (“Sign in to Xale to use this connector.”), and:

```text
WWW-Authenticate: Bearer resource_metadata="https://xale.app/.well-known/oauth-protected-resource/api/mcp", scope="read write:memories write:intentions write:changes"
```

When a token was sent but isn't valid (expired, revoked, unknown), the header adds `error="invalid_token", error_description="Connect the app to Xale again."`

| Document | Address | Standard |
| --- | --- | --- |
| Protected resource metadata | `/.well-known/oauth-protected-resource` and `/.well-known/oauth-protected-resource/api/mcp` | RFC 9728 |
| Authorization server metadata | `/.well-known/oauth-authorization-server`, also served at `/.well-known/openid-configuration` | RFC 8414 |

Both are public, with `Cache-Control: public, max-age=300`. The authentication challenge lists the default AI scopes. The discovery documents also advertise `read:now` for a display-only client.

## Authorization server metadata

| Field | Value |
| --- | --- |
| `issuer` | `https://xale.app` |
| `authorization_endpoint` | `https://xale.app/oauth/authorize` (a Xale page) |
| `token_endpoint` | `https://xale.app/api/oauth/token` |
| `registration_endpoint` | `https://xale.app/api/oauth/register` |
| `revocation_endpoint` | `https://xale.app/api/oauth/revoke` |
| `scopes_supported` | `read`, `read:now`, `write:memories`, `write:intentions`, `write:changes`, `offline_access` |
| `response_types_supported` | `code` |
| `response_modes_supported` | `query` |
| `grant_types_supported` | `authorization_code`, `refresh_token` |
| `code_challenge_methods_supported` | `S256` |
| `authorization_response_iss_parameter_supported` | `true` |

## The authorization request

Parameters read: `client_id`, `redirect_uri`, `response_type`, `code_challenge`, `code_challenge_method`, `state`, `scope`, `resource`. Any of them sent twice is refused.

| Check | If it fails |
| --- | --- |
| `client_id` is a registered client | Xale's page says so; no redirect |
| `redirect_uri` matches a registered one (it may be left out when the client registered exactly one) | Xale's page says so; no redirect |
| `state` is at most 2,048 characters | Xale's page says so; no redirect |
| `response_type=code` | Redirect with `unsupported_response_type` |
| `code_challenge` is 43 characters: letters, digits, `-` and `_` | Redirect with `invalid_request` |
| `code_challenge_method=S256` | Redirect with `invalid_request` |
| `resource`, if sent, is `https://xale.app/api/mcp` (a trailing slash is ignored) | Redirect with `invalid_target` |
| Every scope is one Xale offers (identity scopes are ignored) | Redirect with `invalid_scope` |

Request `scope=read:now` explicitly for a display. Consent offers only the display permission. See [Scopes](https://xale.app/docs/ai/scopes-what-each-allows) for the scope combinations and [Now and Up Next](https://xale.app/docs/ai/tools/xale_read_now) for the desktop Python example.

Every redirect back carries `iss=https://xale.app`, and `state` when you sent it.

## What the person sees

- Signed out: a preview of who is asking, and **Sign in to Xale**. **Cancel** returns `access_denied`.
- Signed in: the app's name, “It will be able to:”, the read permission, and each write permission as a box they can untick, then **Allow** or **Cancel**.
- On a Free account the page says “Connecting your own AI to Xale is part of Xale Pro.” instead of a working **Allow**. See [Xale Pro · required for connecting](https://xale.app/docs/ai/xale-pro-required-for-connecting).

The app's name comes from its callback address, never from its own `client_name`: Claude, ChatGPT, Grok, “A Google app, such as Gemini”, or, for a loopback address, “An app on this computer (it calls itself “…”)”.

## Timings

| Step | Lasts |
| --- | --- |
| A consent (the page's record of exactly what was asked) | 10 minutes, single use, tied to the account that opened it |
| The authorization code | 5 minutes, single use |

On **Allow**, Xale starts a fresh connection and returns the code; any earlier connection of the same client ends. If the account has no time zone saved, the browser's zone is saved then.

## The token request

`POST /api/oauth/token`, form-encoded: `grant_type=authorization_code`, `code`, `code_verifier` (43–128 characters), `client_id`, and `redirect_uri` when you sent one to ask. The answer and refresh rules are on [Tokens · expiry and refresh](https://xale.app/docs/ai/tokens-expiry-and-refresh).

## Related

- For people: [Why does Xale keep asking me to sign in when I connect Claude?](https://xale.app/help/sign-in-loop-when-connecting)
- For people: [How do I connect Claude to Xale?](https://xale.app/help/connect-claude-web-and-desktop)
- For people: [How do I sign in to Xale with Google, Apple or email?](https://xale.app/help/sign-in-google-or-email)
- Read next: [Dynamic client registration · details](https://xale.app/docs/ai/dynamic-client-registration-details)
- Read next: [Scopes · what each allows](https://xale.app/docs/ai/scopes-what-each-allows)
- Read next: [Tokens · expiry and refresh](https://xale.app/docs/ai/tokens-expiry-and-refresh)
