# Sign in with Keystone

Register your app in Developers under OAuth apps. Register the full callback URI. Keep a confidential client's secret on your server. Choose a public client for an installed app or CLI.

## Discovery

GET https://keystonecloud.ai/.well-known/oauth-authorization-server/oauth2. Use the issuer and endpoints from this document.

## Authorization code with PKCE

Generate a random state and a fresh verifier of 43 to 128 URL-safe characters. Hash the verifier with SHA-256 and encode the digest as unpadded base64url.

Open /oauth2/authorize with response_type=code, client_id, redirect_uri, scope, state, code_challenge and code_challenge_method=S256. Separate scopes with spaces. The user selects an account and workspaces. At your callback, verify state and iss before using the code.

Send a form-encoded POST to /oauth2/token with grant_type=authorization_code, client_id, redirect_uri, code and code_verifier. Codes expire in five minutes. Confidential clients authenticate using HTTP Basic or client_secret in the form.

## Device authorization

POST client_id and scope to /oauth2/device_authorization. Show verification_uri and user_code on the device. The user enters the code at /activate and reviews the permissions. Poll /oauth2/token with client_id, grant_type=urn:ietf:params:oauth:grant-type:device_code and device_code. Wait interval seconds between polls. Continue on authorization_pending. Add five seconds on slow_down. Stop on access_denied or expired_token.

## Access and renewal

Send Authorization: Bearer ACCESS_TOKEN to /v1/me, /oauth2/userinfo or /v1/tools. Both profile endpoints require account.read. Include mcp to connect to /mcp. Each tool also requires its own permission.

Access tokens expire in one hour. POST grant_type=refresh_token, client_id and refresh_token to /oauth2/token to renew. Store both replacements together. Refresh tokens expire after 30 days. A lost response can be retried with the previous refresh token for 60 seconds. A later replay revokes the grant.

POST client_id and token to /oauth2/revoke. Revoking a refresh token disconnects the grant. Users can also disconnect an app from Account.

## Scopes

Workflow and trigger mutations, outbound webhook subscriptions and stored webhook event payloads, Computer command execution, and agent or mission prompting are not granted to OAuth apps.

- account.read  Read your profile, email, plan and workspace list.
- workspaces.read  List workspaces and read workspace settings, memory and workflow definitions.
- workspaces.write  Create and update workspaces and memory.
- apps.read  Search connected apps and inspect their schemas and connection status.
- apps.run  Run actions in connected apps and change their records.
- computers.read  Inspect computers and read files.
- computers.write  Write files and manage computer snapshots.
- computers.exec  Computer command execution is unavailable for connected apps.
- sites.read  Read sites, domains and DNS records.
- sites.write  Deploy sites, edit pages and manage domains.
- phone.read  Read calls, messages and inbox threads.
- phone.write  Send texts, make calls and manage phone numbers.
- wallet.read  Read your balance and usage summaries.
- mcp  Connect through MCP using the permissions listed here.
