# Authentication

AI Game Developer uses OAuth 2.1 with the device-authorization flow everywhere — the editor window, the desktop app, and the Unity / Unreal / Godot CLIs. You approve a sign-in in your browser and credentials are stored on your machine. Personal Access Tokens stay available for CI and manual MCP clients.

_Last updated: 2026-07-18_

## OAuth device flow — the default

Every entry point — the editor window, the app, and each CLI — signs in the same way: it opens your browser, you approve the device, and it stores the full credential set locally. Nothing to copy or paste.

1. Start the flow — Authorize in the editor window, Sign in in the app, or login in a CLI.
2. Approve the device code in the browser window that opens (same ai-game.dev account).
3. Credentials are stored on your machine; access tokens refresh automatically.
4. The session appears on your Connected devices page (/app/connected-devices), where you can revoke it any time.

### Three ways it starts

- Editor window — choose Cloud, click Authorize, approve in the browser.
- Game Dev App — click Sign in; the app opens the same browser flow (see /docs/app).
- CLI — run login (e.g. unity-mcp-cli login); it opens the browser and stores credentials.

```bash
# Unity / Unreal / Godot — same OAuth device flow
unity-mcp-cli login
unreal-mcp-cli login
godot-cli login
```

## Endpoint: /mcp vs /mcp/p/<pin>

The hosted MCP endpoint is https://ai-game.dev/mcp. /mcp is the base endpoint — the server routes to one of your connected editors by fallback (a single editor, most-recently-used, or a sticky selection). /mcp/p/<pin> is a pinned URL: the pin is derived from a project's identity, so requests are routed to that exact project's editor.

setup-mcp writes the pinned /mcp/p/<pin> URL into your client config by default (pass --no-pin to fall back to the base /mcp URL). The written config is credential-free — the client authorizes over OAuth on first connect.

```bash
# Writes a pinned /mcp/p/<pin> URL for your AI client (e.g. Claude Code)
unity-mcp-cli setup-mcp claude-code
godot-cli setup-mcp claude-code
unreal-mcp-cli setup-mcp claude-code --path ./YourProject
```

### Enroll

When an AI agent hands you an enrollment code, run the CLI's enroll to bind that agent to your project — it writes the same project pin, so the agent is routed to the right editor. Regular setup-mcp already handles the common case; enroll is the "the agent gave me a code" path.

## Personal Access Tokens — for CI and manual clients

Prefer a static token for CI pipelines, scripts, or a manual MCP client that can't do an interactive browser login? Mint a Personal Access Token from your API keys page (/app/api-keys) and send it as a bearer token. PATs are the manual alternative to OAuth, not the default path.

```json
{
  "mcpServers": {
    "ai-game-dev": {
      "url": "https://ai-game.dev/mcp",
      "headers": { "Authorization": "Bearer YOUR_PERSONAL_ACCESS_TOKEN" }
    }
  }
}
```

Full request anatomy and per-client snippets live on the MCP endpoint page (/mcp-endpoint-info).

---

Source (HTML): https://ai-game.dev/docs/auth
