# auth.md

You are an agent acting for a person with a Rig account. This file is how you get a credential for Rig Cloud MCP.

Audience: `https://api.userig.app/mcp` for that account. The Mac app’s local MCP hub runs on their machine and is not this website.

## Discovery

Protected resource metadata:

- https://api.userig.app/.well-known/oauth-protected-resource
- Resource: `https://api.userig.app/mcp`
- Authorization servers: `https://api.userig.app`
- Scopes: `openid`, `profile`, `email`, `offline_access`
- Bearer method: `Authorization` header

Authorization server metadata (issuer `https://api.userig.app`):

- https://api.userig.app/.well-known/oauth-authorization-server
- https://api.userig.app/.well-known/openid-configuration

Those API documents are the source of truth. The authorization server document includes this `agent_auth` block:

```json
{
  "skill": "https://userig.app/auth.md",
  "register_uri": "https://api.userig.app/api/auth/oauth2/register",
  "revocation_uri": "https://api.userig.app/v1/account/api-tokens/{id}/revoke",
  "credential_types_supported": ["api_key", "access_token"],
  "claim_uri": "https://api.userig.app/v1/account/agent-auth/claim",
  "identity_types_supported": ["identity_assertion"],
  "identity_assertion": {
    "assertion_types_supported": ["verified_email"],
    "credential_types_supported": ["api_key", "access_token"]
  }
}
```

`register_uri` is OAuth dynamic client registration. It registers a client. It does not accept an agent identity assertion. `api_key` is a personal access token (prefix `rig_at_`) sent as `Authorization: Bearer`. `access_token` is the token from the OAuth authorization-code grant. `revocation_uri` revokes an API token: replace `{id}` with the token id from create or list, and send the person's signed-in session. There is no OAuth token revocation endpoint.

`claim_uri` is the verified-email registration method. `identity_types_supported` lists `identity_assertion` for that method. The only assertion type is `verified_email`. Rig does not accept anonymous registration or ID-JAG assertions.

Email and password, and magic link, are how a person signs in.

## Registration

A person creates the Rig account, then provisions a credential for you. Supported methods are a verified-email claim, an API token, and OAuth on the authorization server above.

### Verified email

You have the person's email. Post it to `claim_uri`. Rig does not email the code. You show the person a code and a link. They sign in and submit the code on that page. You then collect one `rig_at_` API token.

1. `POST https://api.userig.app/v1/account/agent-auth/claim` with `{ "type": "service_auth", "login_hint": "person@example.com" }`. The same call accepts `{ "email": "person@example.com" }` or `{ "type": "identity_assertion", "assertion_type": "verified_email", "assertion": "person@example.com" }`. Add `"client_name": "Your agent"` so the person sees which agent is asking.
2. The response includes `claim_token` once, `claim.user_code`, and `claim.verification_uri`. The claim expires in 10 minutes. `claim.interval` is 5 seconds. Do not send the code back to Rig yourself, and do not ask the person to paste the code into the chat.
3. The person opens `verification_uri`, signs in at https://api.userig.app/account if they are not already signed in, and reopens the link. The signed-in email must match `login_hint` and must already be verified. The page shows your `client_name`, the IP address and device the claim came from, and when it was made. They submit `user_code` on that page, with a code from their authenticator app unless they signed in within the last 15 minutes. Opening the link does not finish the claim. A request without a signed-in session does not finish it.
4. Poll `POST https://api.userig.app/v1/account/agent-auth/claim/token` with `{ "claim_token": "<claim_token>" }` no more often than `claim.interval`. Until they confirm, the JSON error is `authorization_pending`. Polling faster returns `slow_down`. After they confirm, the response includes `access_token` once. That value is an API token (`rig_at_`) with the `mcp` scope that expires after 30 days, `credential_type` `api_key`, and `token_id` for revocation. The claim token does not work again.
5. If the claim expires first, start again at step 1. Revoke the API token later with the person's signed-in session at `revocation_uri`, using `token_id`.

`GET` on `claim_uri` describes the method and does not create a claim. Anonymous bodies return `anonymous_not_enabled`. ID-JAG bodies return `invalid_request`.

### Account

- Sign up: https://api.userig.app/account/signup
- Create the account: `POST https://api.userig.app/api/auth/sign-up/email`
- JSON body: `{ "email", "password", "name", "callbackURL": "/account" }`
- Password length: at least 12 characters. The person confirms the address from the inbox.
- Sign in: https://api.userig.app/account
- Email and password: `POST https://api.userig.app/api/auth/sign-in/email` with `{ "email", "password" }`
- Magic link for an existing account: `POST https://api.userig.app/api/auth/sign-in/magic-link` with `{ "email", "callbackURL": "/account", "errorCallbackURL": "/account" }`
- Accounts use email. There is no social login.

### API token

The signed-in person (cookie session) creates a personal access token:

- Dashboard: https://api.userig.app/account/dashboard#security
- Create: `POST https://api.userig.app/v1/account/api-tokens` with `{ "name": "label" }`
- The JSON response includes `token` once. Tokens start with `rig_at_`. Default scope is `acp`.
- List: `GET https://api.userig.app/v1/account/api-tokens`
- Revoke, same session: `POST https://api.userig.app/v1/account/api-tokens/{id}/revoke`

### OAuth

Use the live authorization server metadata. Grant types there are `authorization_code` and `refresh_token`. PKCE method is `S256`. Scopes are `openid`, `profile`, `email`, and `offline_access`.

- Authorize: `https://api.userig.app/api/auth/oauth2/authorize`
- Token: `https://api.userig.app/api/auth/oauth2/token`
- Userinfo: `https://api.userig.app/api/auth/oauth2/userinfo`
- End session: `https://api.userig.app/api/auth/oauth2/endsession`
- OAuth client registration: `POST https://api.userig.app/api/auth/oauth2/register`

Dynamic client registration accepts HTTPS redirect URIs on allowlisted MCP portal hosts (`chatgpt.com`, `openai.com`, `claude.ai`, `claude.com`, `smithery.ai`). It registers an OAuth client. The person still approves access in the browser before the token endpoint returns an access token. Public clients use PKCE with `token_endpoint_auth_method` `none`.

## Use the credential

Send the API token or the OAuth access token on the resource:

```http
POST /mcp HTTP/1.1
Host: api.userig.app
Authorization: Bearer <token>
Content-Type: application/json
```

A missing or rejected token returns 401. `WWW-Authenticate` is `Bearer` and includes `resource_metadata="https://api.userig.app/.well-known/oauth-protected-resource"`.
