aindrive/docs

Authentication

Every endpoint takes a bearer token: Authorization: Bearer <token>. The token decides which drives you can reach and a ceiling on what you can do. The ceiling is never a grant — each call is re-checked against the user's current role and path-scoped permissions, so removing someone from a drive (or downgrading them) takes effect immediately for every token they hold.

TokenPrefixReachHow you get it
Personal access tokenaind_pat_one drive, read or writedrive → sidebar MCP → Generate (shown once; 30d / 90d / never)
OAuth drive tokenaind_oat_ (+ refresh aind_ort_)one drive, drive:read / drive:writeOAuth 2.1 with resource = the drive's MCP URL
OAuth account tokenaind_aat_ (+ refresh aind_art_)every drive the user belongs to, per scope: drives:read, drives:write, drives:sell, wallet:pay, and/or profileOAuth 2.1 with no resource ("Sign in with aindrive")

Where each token works:

/mcp/d/<id>/a2a/agui/agui/d/<id>/api/oauth/userinfo · /api/oauth/drives
aind_pat_ / aind_oat_its driveits drive (pinned)its drive (pinned)its drive—
aind_aat_ + drives:readread tools, any member driveread skillsread skillsread skillsdrives ✓
aind_aat_ + drives:write+ write_file, delete_path+ write skills+ write skills+ write skills—
aind_aat_ + drives:sell+ sale tools (drive creator only)————
aind_aat_ + wallet:pay+ the x402 pay tools (x402_wallet / x402_sign / x402_settle), when the server has agent wallets on————
aind_aat_ + profile————userinfo ✓

Each account scope adds exactly its skills; a skill outside the granted scopes is refused. Write skills still need the user's editor role at the path, and sale tools only work for the drive's creator.

OAuth 2.1

aindrive is a standards-compliant authorization server (the flow MCP hosts run automatically). You only need this if you write your own client.

DiscoveryGET https://aindrive.ainetwork.ai/.well-known/oauth-authorization-server (RFC 8414)
Per-drive resource metadataGET https://aindrive.ainetwork.ai/.well-known/oauth-protected-resource/mcp/d/<driveId> (RFC 9728)
Dynamic client registrationPOST https://aindrive.ainetwork.ai/api/oauth/register (RFC 7591 — public clients only)
AuthorizeGET https://aindrive.ainetwork.ai/oauth/authorize — PKCE S256 required
TokenPOST https://aindrive.ainetwork.ai/api/oauth/token — authorization_code, refresh_token
Scopesper drive: drive:read, drive:write · account: profile, drives:read, drives:write, drives:sell, wallet:pay

1. Register

curl -s https://aindrive.ainetwork.ai/api/oauth/register -H 'content-type: application/json' -d '{
  "client_name": "My App",
  "redirect_uris": ["https://myapp.example/callback"]
}'
# → { "client_id": "aind_client_…", ... }

Redirect URIs: https://…, http://localhost|127.0.0.1 (native apps), or a private-use scheme (myapp://…). Registration is rate-limited.

2. Send the user to authorize

https://aindrive.ainetwork.ai/oauth/authorize?response_type=code
  &client_id=aind_client_…
  &redirect_uri=https://myapp.example/callback
  &code_challenge=<BASE64URL(SHA256(verifier))>&code_challenge_method=S256
  &state=<random>
  &scope=drive:read%20drive:write          ← account grant: e.g. profile%20drives:read
  &resource=https://aindrive.ainetwork.ai/mcp/d/<driveId>       ← omit for an account grant

The user signs in (email or wallet) and approves on aindrive's consent screen; they can lower the permission. You get ?code=…&state=…&iss=https://aindrive.ainetwork.ai back. (Apps the server's operator lists as its own first-party apps skip the consent screen for people signed in with their AIN account, and never for payment or sale scopes; every other app always gets it.)

3. Exchange and refresh

curl -s https://aindrive.ainetwork.ai/api/oauth/token -d grant_type=authorization_code \
  -d code=$CODE -d client_id=$CLIENT_ID -d redirect_uri=$REDIRECT -d code_verifier=$VERIFIER
# → { access_token, refresh_token, token_type:"Bearer", expires_in:3600, scope }

curl -s https://aindrive.ainetwork.ai/api/oauth/token -d grant_type=refresh_token -d refresh_token=$RT -d client_id=$CLIENT_ID

Access tokens live 1 hour; refresh tokens 30 days and rotate on every use. Replaying an old refresh token revokes the whole grant (it means the token leaked). Codes are single-use and expire in 10 minutes.

Revoking

Users see every token and connected app in the drive's MCP panel (drive tokens) and can revoke them there; drive owners see and revoke all members' tokens. Account grants are listed at GET /api/oauth/account-tokens and revoked with DELETE /api/oauth/account-tokens/<id>.