Logging an agent in¶
Most agents reach their model without this page. A pi agent — the default runtime — boots on
a provider API key written with agentctl secret set, and that is the whole of its model
auth. agentctl login covers the OAuth flows: claude's model subscription, and the accounts
behind the Google and Microsoft MCPs, which either runtime can be wired to.
agentctl login <provider> <name>|self
Providers: claude, google, ms365, atlassian, powerbi. Every login
and install preflights its secrets and refuses with the exact agentctl secret set … fix
line.
| provider | method | with the auth broker | without a broker |
|---|---|---|---|
| ms365 | device-code | open the URL, enter the code | same |
| claude | PKCE | the agent posts the link in the cockpit → paste the code#state back |
same |
| redirect | click the DM'd link; the broker catches the code | copy the localhost URL → login google … --code <url> |
|
| atlassian | PKCE + Dynamic Client Registration | click the DM'd link; the broker catches the code | copy the URL → login atlassian … --code <code> |
| powerbi | PKCE (delegated Fabric token) | click the DM'd link; the broker catches the code | refused — broker required |
A claude agent, in the cockpit¶
An agent added with --runtime claude signs in to a claude.com account instead of carrying
an API key, and agents add provisions it without logging it in. Open the cockpit against one
whose credentials are dead or absent and the web-view tier posts an auth card into the chat,
ahead of any turn.
- Open the
claude.comauthorize link in a browser already signed in to the account the agent should run as. - Click Authorize. The page shows a
code#statestring. - Paste that whole string — both halves and the
#— into the cockpit as the next message.
The paste is intercepted before it becomes a turn, exchanged for credentials written under
the agent's own home, and the unit restarts logged in. The agent answers with a ✅.
/login issues a fresh link at any point; the first one expires.
The card and the /login command belong to this runtime alone — see
Runtimes for the rest of what differs.
Google Workspace: the console setup behind login google¶
login google needs an OAuth client that is yours, in your own Cloud project. The consent
screen requests 8 scopes, which means enabling 6 APIs:
gmail.modify · gmail.send · drive · drive.file · calendar · documents ·
spreadsheets · presentations
⇒ enable gmail · drive · calendar-json · docs · sheets · slides
In the Cloud Console: create or select a project → APIs & Services → Enable those 6 →
OAuth consent screen → User type Internal, which needs no verification and gives the
refresh token no 7-day expiry → Credentials → Create OAuth client ID → type Web
application for the broker, or Desktop for the loopback flow → on Web, add the
authorized redirect URI https://<BROKER_URL>/oauth/callback.
gcloud covers the project and the API enablement; the consent screen and the client ID
have no API and stay clicks:
gcloud projects create agentctl-fleet
gcloud services enable gmail.googleapis.com drive.googleapis.com \
calendar-json.googleapis.com docs.googleapis.com sheets.googleapis.com \
slides.googleapis.com --project agentctl-fleet
Then the two secrets, the MCP and the login:
agentctl secret set GOOGLE_CLIENT_ID --value <…apps.googleusercontent.com>
agentctl secret set GOOGLE_CLIENT_SECRET --value <secret>
agentctl mcp add google-workspace <agent>
agentctl login google <agent>|self
Google Workspace is a capability an agent is wired into on any channel, not a channel of its own — see MCPs.
Auth broker (optional)¶
The broker is a redirect-flow convenience, and applies to google, atlassian and
powerbi: all three need a redirect on an OAuth client agentctl owns (atlassian registers
its own public PKCE client per agent via DCR, discarding any client secret Atlassian returns —
its token auth method is none). claude uses a vendor app with a fixed redirect, so it never
touches the broker; ms365 defaults to device-code but also has a broker branch, which
login ms365 picks when a broker is configured.
powerbi is the one provider with no non-broker path. login powerbi refuses outright when
BROKER_URL is unset rather than falling back to device-code, and mints a delegated Fabric
token into ~/.powerbi-mcp/token-cache.json — a separate resource from Graph, so an ms365
login does not authorize it and the two caches never merge. Set POWERBI_MCP_CLIENT_ID and
POWERBI_MCP_TENANT_ID first. POWERBI_MCP_CLIENT_SECRET is optional and turns the Entra app
registration into a confidential client; set it at either scope — shared or --agent — since
the connector's unit sources both env files.
agentctl secret set BROKER_URL --value https://auth.example.com # your DNS/TLS host
agentctl auth-broker install # generates BROKER_HMAC_KEY, binds :8734
# then register ONE redirect URI per OAuth client (Google console → Authorized redirect URIs):
# https://auth.example.com/oauth/callback
Front BROKER_PORT (:8734) with your own HTTPS reverse proxy, public URL → :8734. TLS and DNS
are yours, not agentctl's.
The signed-state flow¶
| step | what happens |
|---|---|
| 1 | login google mints a signed, single-use state, 10-minute TTL |
| 2 | it sets redirect_uri=$BROKER_URL/oauth/callback on a Web-type client |
| 3 | it registers the pending auth with agentd and DMs the link |
| 4 | the human clicks the link; Google redirects to GET /oauth/callback?code=&state= |
| 5 | the broker verifies the HMAC, then hands (state, code) to agentd over /run/agentctl.sock |
| 6 | agentd consumes the state single-use, then runs the token exchange as that agent |
The state is HMAC-SHA256 over agent, nonce and expiry, keyed by BROKER_HMAC_KEY. A replayed,
expired or unknown state is rejected. The OAuth code travels only over the local socket, and
nothing is logged.