# OneTapVote auth.md

How an AI agent or MCP client gets access to a person's OneTapVote account: create polls, read poll results and account stats.

## Who this is for

Agents acting for a person who has a OneTapVote account. Every credential belongs to that person's account and acts only on its polls. There is no anonymous or agent-only access: the person creates the account at https://onetapvote.com/sign-up (free; new accounts get a Pro trial).

Public pages, https://onetapvote.com/llms.txt and the agent skills (https://onetapvote.com/.well-known/agent-skills/index.json) need no credential.

## Protected resources

| Resource | URL | Metadata (RFC 9728) |
| --- | --- | --- |
| MCP server (Streamable HTTP) | `https://onetapvote.com/api/mcp` | https://onetapvote.com/.well-known/oauth-protected-resource/api/mcp |
| Whole API: REST `https://onetapvote.com/api/v1` and the MCP server | `https://onetapvote.com` | https://onetapvote.com/.well-known/oauth-protected-resource |

Send the credential as `Authorization: Bearer <token or key>`. Cookies and tokens in the query string are not accepted.

## Option 1: OAuth 2.1 (MCP connectors, recommended)

1. Discover: call the resource without a credential. It answers 401 with `WWW-Authenticate: Bearer resource_metadata="…"`; the MCP server points to its own metadata, the REST API to the root metadata.
2. Read the authorization server metadata at https://onetapvote.com/.well-known/oauth-authorization-server/api/auth (issuer `https://onetapvote.com/api/auth`).
3. Register the client with Dynamic Client Registration (RFC 7591) at its `registration_endpoint`. No initial access token is needed; a public client uses `token_endpoint_auth_method: none`.
4. Send the person to the `authorization_endpoint`: authorization code with PKCE (`S256` only), and `resource` set to the resource from step 1 (RFC 8707). Add `offline_access` to the scope to get a refresh token. The person signs in to OneTapVote (email and password, or Google) and approves the app on the consent page.
5. Exchange the code at the `token_endpoint`. The access token is a JWT for that resource and lasts 1 hour; the refresh token lasts 30 days and is replaced on every use.
6. Call the resource with `Authorization: Bearer <access token>`.
7. To end access, revoke the token at the `revocation_endpoint` (RFC 7009). The person can also disconnect the app in their dashboard (Account settings, API tab, Connected apps), which stops its tokens at once.

## Option 2: API key

1. The person creates a key in their OneTapVote dashboard (Account settings, API tab) and gives it to you. Keys start with `otv_live_` and are shown once.
2. Send `Authorization: Bearer otv_live_…` to the REST API or the MCP server.
3. The person revokes the key in the same place.

An agent cannot create keys itself. Never ask for the person's password.

## What a credential can do

- Any plan: list polls, read poll results and account stats.
- Pro or Business plan: create and publish polls. On the Free plan the REST API answers 403 `PLAN_REQUIRED` and the MCP tool returns an error with the upgrade link (https://onetapvote.com/pricing).
- Nothing edits, closes or deletes a poll, or touches billing or account settings.
- Limits per API key or OAuth connection: REST 60 reads and 10 writes a minute; MCP 60 requests a minute, of which 10 new polls. Over the limit the answer is 429.

## Errors

- 401 with `WWW-Authenticate`: the credential is missing, expired or revoked, or the person disconnected the app. Refresh the token or sign in again.
- 403 `PLAN_REQUIRED`: creating polls needs a paid plan.
- 429: wait a minute.

## Discovery documents

- https://onetapvote.com/.well-known/oauth-protected-resource
- https://onetapvote.com/.well-known/oauth-protected-resource/api/mcp
- https://onetapvote.com/.well-known/oauth-authorization-server/api/auth
- https://onetapvote.com/.well-known/mcp/server-card.json (MCP tools, readable without signing in)
- https://onetapvote.com/.well-known/api-catalog
- REST API documentation: https://onetapvote.com/docs/api; MCP server documentation: https://onetapvote.com/docs/mcp
