TubeOnAITubeOnAIDevelopers
Skip to Content
TubeOnAITubeOnAIDevelopers

Authentication

Send a credential in the Authorization header:

Authorization: Bearer <token>

The token is either an API key (toa_live_…) or an OAuth access token (toa_at_…) issued to an MCP client or the CLI.

Signing in to the web app

The web app signs you in with Google, Apple or an emailed sign-in link. A bearer token can't start a browser session.

  • Request: POST /v1/auth/magic-link with {"email": "...", "redirect_to": "/library"} answers 202 whether or not the address has an account. The email holds a sign-in link and a 6-digit code. Both expire after 15 minutes and work once.
  • Open the link: it opens a confirm page in the web app. Opening the link doesn't sign you in by itself, so a mail scanner that opens it first can't use it up. The confirm page shows the address and signs you in.
  • Or enter the code: on any device, enter the address and the 6-digit code on the sign-in page. Use this when you read the email on another device. After 5 wrong codes for one email, or 20 for an address in a day, codes stop working; the link still works, or request a new email.
  • Only the newest email works. Requesting another email makes the link and code in every earlier email stop working.
  • Rate limits: an address can request 5 sign-in emails per hour, and one network (an IPv4 address, or an IPv6 /64) 20 per hour by default. One network can also try 30 sign-in codes per hour by default, across all addresses. The next request gets 429 RATE_LIMITED with retry_after_sec, the seconds until another request is accepted. If the limit service is down, requests fail with 503 SERVICE_UNAVAILABLE rather than skipping the limit. A request that fails the bot check doesn't count against its network's email limit.
  • Bot check: when GET /v1/client-config returns a sign_in.turnstile_site_key, the sign-in page runs a Cloudflare Turnstile check and sends its token as turnstile_token with the request. A missing, expired or failed token gets 422 BOT_CHECK_FAILED (retryable: true): complete the check and try again. Most visitors never see the check. When the key is null, no token is needed.
  • Privacy: the sign-in page loads Cloudflare Turnstile from challenges.cloudflare.com when the bot check is on, and sign-in sets a first-party toa_device cookie (a random ID, kept 400 days). TubeOnAI stores only a hash of that ID and the signup's network, to spot many accounts created from one browser or network.
RouteBodySuccessErrors
POST /v1/auth/magic-link/inspect{"token"}200 {"email", "expires_at"}; doesn't use the link410 SIGN_IN_LINK_INVALID
POST /v1/auth/magic-link/confirm{"token"}200 {"redirect_to"} and the session cookies410 SIGN_IN_LINK_INVALID
POST /v1/auth/magic-link/verify-code{"email", "code"}200 {"redirect_to"} and the session cookies422 SIGN_IN_CODE_INVALID (wrong code, try again), 422 VALIDATION_FAILED (not 6 digits), 410 SIGN_IN_LINK_INVALID (too many wrong codes), 429 RATE_LIMITED (too many codes from this network). With no sign-in pending it answers 422 SIGN_IN_CODE_INVALID, so it never reveals whether an address has one.

SIGN_IN_LINK_INVALID means the link has expired, was already used, or a newer email was sent.

Where a bearer token works

Bearer tokens are accepted only on these routes:

RouteUse
/mcpThe MCP server
/v1/ai/*Transcripts, uploads, podcast discovery, account summary
GET /v1/meWho you are and your workspaces

Every other signed-in route of the TubeOnAI API accepts only a browser sign-in. A bearer token sent to one of those routes gets 401 UNAUTHENTICATED, even when the token is valid. Public routes, such as health checks, /oauth/* and client configuration, ignore the header. You can't create keys, list connected apps or reach billing endpoints with a bearer token.

Workspaces

Each token belongs to one user and one workspace:

  • An API key belongs to the workspace you were in when you created it.
  • An OAuth connection belongs to the workspace you chose when you selected Allow.

Calls act in that workspace. You may send X-Workspace-Id, but it must name the token's own workspace. Any other value returns 404 NOT_FOUND. If you leave the workspace, calls with its tokens return 404 NOT_FOUND.

Scopes

ScopeAllows
transcriptsReading transcripts, your library and projects, and your account. Every connection has it.
library:writeAdding to and deleting from your library, and creating, changing and deleting projects.
publishListing your publishing destinations and posts, and publishing, scheduling, rescheduling and cancelling posts to your connected accounts.

The consent page lists the scopes a client asks for before you choose Allow, and the token response's scope names what was granted. A refreshed token keeps its scopes; to change them, connect again. OAuth clients that ask for no scope receive transcripts. Clients may also ask for common extra scopes, such as offline_access or openid, which are ignored. A request for only unknown scopes is refused with invalid_scope. Approving sends back the scopes the consent page showed; if the request asks for others (a stale page), approval fails with 409 CONSENT_OUTDATED and the page reloads them. A call the token wasn't granted returns 403 INSUFFICIENT_SCOPE with details.required_scope. API keys don't have scopes: they can do everything. tubeonai login asks for all three scopes.

API keys

Create and revoke keys in Settings → AI & developer tools → API. You must be signed in to the web app; a bearer token can't manage keys.

  • Create: name the key (1–60 characters), then copy the secret. It is shown only once. TubeOnAI stores only a hash.
  • Identify: the list shows each key's name, its first 12 characters (for example toa_live_AbC…) and when it was last used.
  • Revoke: choose Revoke. The key stops working at once.
  • Rotate: create a new key, switch your code to it, then revoke the old key. There is no automatic rotation or expiry.

API keys don't expire. Keep them out of source control and client-side code. Revoke a key straight away if it leaks.

The CLI accepts a key through TUBEONAI_API_KEY. The key takes precedence over a stored login.

OAuth (MCP clients and the CLI)

MCP clients find everything they need automatically. You only paste the MCP URL. For client authors, the server supports:

ItemValue
DiscoveryGET /.well-known/oauth-authorization-server (RFC 8414); GET /.well-known/oauth-protected-resource/mcp (RFC 9728)
Client registrationPOST /oauth/register (dynamic client registration, RFC 7591). Public clients only: token_endpoint_auth_method must be none. 1–10 redirect URIs.
AuthorizationGET /oauth/authorize: authorization code with PKCE. Only S256 is supported.
Device loginPOST /oauth/device_authorization (RFC 8628). Only verified clients, such as the TubeOnAI CLI, may use it.
TokenPOST /oauth/token: grant types authorization_code, refresh_token and urn:ietf:params:oauth:grant-type:device_code
RevocationPOST /oauth/revoke (RFC 7009) for access and refresh tokens. It does not revoke API keys.
Resource<issuer>/mcp. Use exactly the MCP URL shown on the AI tools page.

Token lifetimes:

  • Access tokens (toa_at_…) last 1 hour.
  • Refresh tokens (toa_rt_…) last 90 days and rotate on every use. If a client uses an old refresh token again, or two refreshes of the same token race, TubeOnAI revokes the whole connection. The user then has to connect again.
  • Device codes last 10 minutes. Poll the token endpoint no faster than every 5 seconds.

/oauth/* endpoints return standard OAuth errors ({"error": "...", "error_description": "..."}), not the API error envelope.

An unauthenticated call to /mcp, or a call with a bad or revoked token to any bearer route, gets 401 with this header:

WWW-Authenticate: Bearer resource_metadata="<issuer>/.well-known/oauth-protected-resource/mcp"

MCP clients use it to start sign-in again.

Connect screen

When a client connects, TubeOnAI opens a consent page showing the app's name. Apps that registered themselves show "This app isn't verified by TubeOnAI" and the address they will return to. Check that you started the connection yourself before you choose Allow. Cancel returns access_denied to the app.

CLI login

tubeonai login starts a device login. It opens the TubeOnAI device page in your browser and prints a code. Enter or confirm the code from your terminal on that page, then allow access. The CLI keeps its tokens in the macOS Keychain or the Linux Secret Service. Without either, it uses ~/.config/tubeonai/credentials.json with mode 0600. tubeonai logout revokes the tokens and deletes them.

Disconnecting apps

Settings → AI & developer tools → Connected apps lists every app connected to the current workspace, when it connected and when it was last used. Disconnect ends every token that app holds for you in that workspace at once. The app's next call gets 401, and it must connect again.

On this page