Should I actually answer this?Sounds simple. It’s not. Hidden inside that one question are really two questions, and most tutorials smush them together and make a mess. Picture a stranger at your door holding an envelope. Before you let them in, you want to know:
- Who are they? The name on the envelope could be real. It could also be something they scribbled on the bus.
- Are they allowed in? Even if the name is real — do they have permission to enter this room, right now?
| Question | What answers it | Where it lives |
|---|---|---|
| Are you allowed to make this request? | Authentication (this page) — a token from a trusted service | OAuth 2.0 / Ory Hydra |
| Is this request really from who it claims to be? | DID signing — a signature only the real person can make | DID page |
Bearer tokens — the movie ticket trick
Ever been to a movie? The person at the door doesn’t ask your name, your address, your favourite childhood pet. They just want to see your ticket. You hand it over, they tear off the stub, you walk in. The ticket is the proof. Whoever’s holding it gets in. That’s literally why it’s called a bearer token — “bearer” meaning “whoever’s bearing it right now.”Your cat could walk in with your bearer token and the movie theatre wouldn’t stop them. Your cat would not enjoy the movie.
- They expire. Bindu tokens last about an hour. If one leaks, the damage window is small.
Where do tokens come from? Meet Hydra
OK — but who gives out the tokens? Not the agent, surely. That’d be like asking the movie theatre door-checker to also run the ticket booth. Too much trust in one place. Bindu uses a separate service whose entire job is issuing and validating tokens: Ory Hydra. It’s an open-source OAuth 2.0 server. Battle-tested. Used by serious companies. We don’t build our own, because “token issuance” is one of those things that looks easy, is actually full of foot-guns, and gets one tiny thing wrong and suddenly the internet has access to everything. Hydra shows up as two URLs:| URL | Purpose | Who talks to it |
|---|---|---|
https://hydra.getbindu.com | Public — hands out tokens. Endpoints like /oauth2/token. | Clients (your code, Postman, the gateway) |
https://hydra-admin.getbindu.com | Admin — registers clients, checks if a token is valid. Endpoints like /admin/*. | Agents, registration scripts |
The whole flow, from zero to answered
Here’s what happens end to end when a client wants to talk to an agent. Three stages, different frequencies:- Step 1 — once per client. You introduce yourself to Hydra. It writes down who you are and gives you a secret. You probably do this once, when a new client is provisioned.
- Step 2 — once per hour. You trade the long-lived secret for a short-lived token. The secret is like a key to your apartment. The token is like a concert wristband — lasts one night.
- Steps 3–5 — every single request. You attach the token. The agent asks Hydra “hey, is this thing still good?” — that question is called token introspection. If yes, request goes through.
What’s actually inside a token?
Nothing readable. The token string itself is random-looking on purpose. All the meaning lives in Hydra’s database. When the agent introspects a token, Hydra sends back something like this:active: true— Hydra still thinks this token is good. Expired or revoked? This flips tofalseand the request is rejected.client_id/sub— who the token belongs to. In Bindu this is almost always a DID. (The DID page explains why.)scope— what rooms of the house this ticket opens.agent:read= read-only.agent:write= can change stuff.exp— when the token turns into a pumpkin. Unix timestamp.iat— when it was issued.
client_id along to the request handler so your code knows who just walked in.
Turning authentication on
Auth is off by default in development, because nobody wants to register a Hydra client just to say hello to localhost. To turn it on, set a handful of environment variables:__) is how Bindu flattens nested config into env vars. AUTH__ENABLED maps to settings.auth.enabled. You don’t need to think about the mapping — just set the variables.
Once your agent starts with these, the middleware:
- Wires itself up to talk to Hydra admin for introspection.
- Rejects any incoming request without a valid
Authorization: Bearer ...header. - Attaches the introspection result to the request so your handler knows who’s calling.
Getting your first token
Register your client with Hydra
Think of this like opening an account at a bank. You hand Hydra your ID, Hydra files the paperwork, gives you a password.Quick notes on each field:
client_id— your agent’s name in Hydra. In Bindu this is always a DID (see the DID page for why).client_secret— the password you’ll use to get tokens. Generate something strong:Store it like a database password. You need it again in the next step.grant_types: client_credentials— “I’m a server, not a human in a browser.” No login forms, no redirects. Swap secret → token.scope— the permissions you want your tokens to carry. Ask for the minimum.token_endpoint_auth_method: client_secret_post— you’ll send the secret in the request body, not a header. Both work; we usepostfor compatibility.
Swap the secret for a token
Once an hour (or the first time, or any time your token is about to expire):Hydra sends back:Copy that
access_token. Keep it in memory. Refresh it before it expires.What can go wrong (and how to read the error)
This is where most beginners lose an afternoon. Here’s the cheat sheet — find your error, fix that thing, not something else.| You see | Most likely because | Fix |
|---|---|---|
401 Unauthorized, no Authorization header | You forgot the token | Add Authorization: Bearer <token> |
401 Unauthorized, introspection says active: false | Token expired | Get a fresh one (step 2 above) |
401 Unauthorized, token doesn’t exist | Token is from a different Hydra than the agent uses | Check HYDRA__ADMIN_URL — agent and client must agree |
invalid_client at the token endpoint | Wrong client_secret, wrong client_id, or the client doesn’t exist yet | Register first, double-check the secret |
invalid_scope at the token endpoint | Asking for a scope you didn’t register with | Register with more scopes, or ask for less |
| Token works for one method, fails for another | That method needs a specific scope you didn’t request | Request the right scope, get a new token |
Finding your credentials again
Two things you’ll need to look up at some point:-
Your agent’s DID — it’s in the agent card:
Look for the
agent.didfield. That’s also yourclient_idfor Hydra. -
Your client secret from
bindufy— saved at.bindu/oauth_credentials.json. Treat that file like.ssh/id_rsa. User-readable only, never committed.
PUTing to /admin/clients/<client_id> with a new secret.
The UI shortcut
The Bindu frontend has a Settings → Authentication page that does step 2 for you. Paste your client secret, click a button, get a token. Handy when you’re poking around in Postman. It’s a convenience. Not a replacement for understanding what’s happening underneath.What’s next
Authentication answers “are you allowed in?” — but in a world where agents talk to agents that talk to other agents, you need something stronger: “are you really who you claim to be?” That’s where DIDs come in. Keep reading.DIDs (next up)
Cryptographic identity — how agents prove they’re really them
API Reference
The full HTTP surface of a Bindu agent