# Otobiz auth.md

Instagram comment to DM, WhatsApp automation, AI replies, one inbox and scheduled posts. AI agents and apps use it through the MCP server at https://mcp.otobiz.ai.

## Current state

Otobiz does not offer agentic registration: no anonymous accounts and no identity assertions. Every credential belongs to a person who signs in and clicks Allow (OAuth 2.1), or is a brand API key an owner or admin creates.

## Discover

1. Call https://mcp.otobiz.ai without a token. It answers 401 with `WWW-Authenticate: Bearer resource_metadata="https://mcp.otobiz.ai/.well-known/oauth-protected-resource"`.
2. Read that document (RFC 9728): the `resource` and its `authorization_servers`.
3. Read https://app.otobiz.ai/.well-known/oauth-authorization-server (RFC 8414): the OAuth endpoints.

## Register your client

Pick one:

- **Client ID Metadata Document** (preferred): use an https URL that serves your client metadata as your `client_id`. No registration call is needed. A loopback redirect it lists (http://localhost or http://127.0.0.1) may use any port.
- **Dynamic Client Registration** (RFC 7591): `POST https://app.otobiz.ai/api/v1/oauth/register` with `client_name` and `redirect_uris`. Public clients (`token_endpoint_auth_method: none`) are accepted.

## Sign in

Send the person to https://app.otobiz.ai/oauth/authorize with `response_type=code`, your `client_id` and `redirect_uri`, the `resource` from step 2 and PKCE (`code_challenge_method=S256`). Name the scopes the job needs from `scopes_supported`; none named is Look only (the reads). The person signs in to Otobiz and clicks Allow. Tell them what you are connecting before you send them.

## Use the credential

POST to https://app.otobiz.ai/api/v1/oauth/token with `grant_type=authorization_code`, the code, your `client_id` and the PKCE verifier. Then send `Authorization: Bearer <access_token>` on every request to https://mcp.otobiz.ai (MCP over Streamable HTTP).

A 401 means the token is missing or expired: use `grant_type=refresh_token`, and if that fails, start again at Sign in.

With no browser, a brand owner or admin creates an API key at https://app.otobiz.ai/apikeys and you send `Authorization: Bearer otbz_…` instead. Never put a credential in a URL.

## Revocation

Access tokens are short-lived. Refresh tokens rotate on every use, so an old one stops working once it has been used. Revoke a token at https://app.otobiz.ai/api/v1/oauth/revoke (RFC 7009).

Keys, scopes and sign-in in full: https://otobiz.ai/developers/authentication.md. All developer docs: https://otobiz.ai/developers/index.md
