# auth.md

This file tells AI agents how to authenticate with PaperGraderPro.

PaperGraderPro is an AI essay grading web app for educators. Public resources (marketing pages, `llms.txt`, agent discovery files) require no authentication. Account-protected API endpoints do.

## Public resources (no auth)

- `GET /api/health` - service health
- `GET /api/og` - Open Graph image generation
- `GET /api/agent-markdown?path=/...` - markdown page content
- `GET /openapi.json` - API description
- `GET /llms.txt` - site documentation for agents

## Step 1 - Discover

Protected resources advertise their metadata at:

```http
GET /.well-known/oauth-protected-resource
```

401 responses from protected APIs also carry a `WWW-Authenticate` header with the `resource_metadata` URL:

```http
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://papergraderpro.com/.well-known/oauth-protected-resource"
```

Authorization server metadata (RFC 8414):

```http
GET /.well-known/oauth-authorization-server
```

## Step 2 - Authenticate

PaperGraderPro uses Supabase-hosted OAuth. The authorization server metadata points to the Supabase project endpoints for the service.

Supported flows for agents:

- **User-authorized browser flow**: email/password or magic link through the Supabase OAuth flow. The resulting session cookie authenticates subsequent API calls from the browser context.
- **Service credentials**: contact support@yourotherai.com for service-level credentials or delegated access for your integration.

Identity assertion (ID-JAG) and device claim ceremonies are not currently supported. We do not mint third-party identity assertions.

## Step 3 - Call the API

Send the access token or session cookie with protected requests:

```http
GET /api/assessments
Authorization: Bearer <token>
```

Scopes supported: `read`, `write`, `grading`.

## Step 4 - Handling revocation

If an API call returns `401`, re-run discovery and re-authenticate. If credentials are revoked, the authorization server rejects them; contact support@yourotherai.com for issues that persist.

## Notes for agents

- Do not store or replay credentials beyond the user's session.
- Public endpoints need no credentials; do not block on them.
- Grading endpoints expect rubric IDs and submission text or uploaded files; see `GET /openapi.json` for schemas.
- The MCP endpoint at `POST /mcp` exposes read-only service information tools without authentication.

This file follows the [auth.md](https://github.com/workos/auth.md) reference format.
