Skip to main content
Save this code as authorization_quickstart.py:
authorization_quickstart.py
authorization=True enables JWT verification. AgentOS also needs a public key to verify tokens against. Generate one from the control plane and wire it in.

Generate a Verification Key from the Control Plane

1

Toggle JWT authorization

Enable JWT authorization when connecting a new AgentOS, or later from the OS Settings page.
2

Copy the public key

Copy the public key for your AgentOS from the modal.
3

Set the verification key

Set the JWT_VERIFICATION_KEY environment variable to your public key in your .env file or export it directly in your terminal:
Or, if you manage keys via a JWKS file, point AgentOS at it instead:
4

Install dependencies

5

Start AgentOS

Authorization is now active for your AgentOS.
The control plane only issues RS256 keys, which is also the default. See authorization troubleshooting for common setup issues.

Sending Authenticated Requests

Authenticated requests carry a verified caller identity and scopes. AgentOS uses the scopes to enforce per-endpoint permissions. Per-user data scoping is opt-in. Enable user_isolation=True as described in Per-User Data Isolation. Send the JWT in the Authorization: Bearer <token> header:
Where the token comes from depends on your issuer:
  • Control plane: minted by os.agno.com and copied from the OS Settings page.
  • Self-hosted: minted by your backend or a third-party IDP. See Self-Hosted for setup.
See JWT Tokens for the claim structure each token must include. Protected requests without a valid JWT return 401 Unauthorized. Requests whose JWT lacks the scopes the endpoint requires return 403 Forbidden.

Configurable Options

Configure JWT verification using AuthorizationConfig:
Use a JWKS file instead:

Environment Variables

Env vars work alongside AuthorizationConfig. Pass keys in code, env vars, or both.

Excluded Routes

These routes are excluded from authorization checks by default: /, /health, /info, /docs, /redoc, /openapi.json, /docs/oauth2-redirect

Error Responses

Next Steps