Skip to content

Commit d3ba56e

Browse files
committed
brainkb skill: PAT-first auth recap + Globus/auth troubleshooting
Add a TL;DR auth order (whoami -> PAT -> Globus bootstrap -> password-never-auto) and a troubleshooting block for the failures seen in practice: Globus unauthorized_client (wrong app type = Service API not Portal), redirect mismatch (USERMANAGEMENT_PUBLIC_BASE_URL), and login-not-persisting on streamable-http (use a PAT/header).
1 parent 1788c6f commit d3ba56e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

skills/brainkb_skills/SKILL.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ adjust the space's access rules.
136136
## Workflows
137137

138138
### 1. Log in
139+
140+
**Auth order (TL;DR) — take the first that applies:**
141+
1. `brainkb_whoami()` → if `authenticated: true` (a PAT/header is already
142+
configured), **stop, you're done.**
143+
2. User has a PAT → `brainkb_use_token("brainkb_pat_…")` (or it's set as
144+
`BRAINKB_TOKEN`). Best for repeated use — survives across calls, no browser.
145+
3. Need to sign in as an account → **Globus** (`brainkb_globus_login`
146+
`brainkb_finish_login`). Then mint a PAT (`brainkb_create_token`) so future
147+
sessions skip the browser.
148+
4. Password (`brainkb_login`) → **only** if the user explicitly has one. Never
149+
prompt for a password on your own.
150+
Always `brainkb_whoami()` again after logging in to confirm the identity stuck
151+
(see the ⚠️ box below). PAT/header = per-call identity (reliable); in-session
152+
login can evaporate on the hosted remote.
153+
139154
**First run `brainkb_whoami()`** — if it already reports `authenticated: true`
140155
(header token or `BRAINKB_TOKEN` PAT is configured), you're done; don't ask for
141156
anything. Otherwise pick a method — **default to Globus, never prompt for a
@@ -181,6 +196,27 @@ password unprompted:**
181196
> `brainkb_use_token`, or an `Authorization: Bearer` header — not an in-memory
182197
> session login on a multi-user remote.
183198
199+
**Troubleshooting login/auth (common failures):**
200+
- **`brainkb_globus_login` → the browser ends on `…?error=unauthorized_client`.**
201+
The Globus app is the **wrong type**: it must be a **"Portal / application you
202+
host"** (confidential OAuth client), NOT a **"Service API"** app. A Service-API
203+
app can't run the login (authorization-code) flow, so Globus rejects it. Fix is
204+
server-side (register a Portal-type app); as the agent, tell the user this rather
205+
than retrying — a new code won't help.
206+
- **`…?error=…redirect… mismatch` / "Mismatching redirect URI".** The backend's
207+
`USERMANAGEMENT_PUBLIC_BASE_URL` doesn't match the redirect registered on the
208+
Globus app (e.g. `localhost` vs the public host, `http` vs `https`, a typo). Also
209+
server-side; retrying won't help.
210+
- **`finish_login` says "Logged in as X" but `whoami` says `authenticated: false`
211+
(or a different user).** The in-session login didn't persist across calls — the
212+
hosted `streamable-http` transport may give each call a fresh session. Don't keep
213+
re-running the browser flow. Switch to a **PAT**: set `BRAINKB_TOKEN` (or
214+
`brainkb_use_token`), which authenticates per-call and survives. On the multi-user
215+
remote, an `Authorization: Bearer` header per request is the intended model.
216+
- **`401` on a call after you were "logged in".** Session/PAT expired — re-auth
217+
(prefer a fresh PAT). `403`, by contrast, means authenticated-but-not-permitted
218+
(a role/capability/access-rule issue), not a token problem.
219+
184220
### 2. Create / choose a workspace (space)
185221
- Individual/private workspace (any write-capable role):
186222
`brainkb_create_space(slug, name, "private", description)` (space_type defaults to

0 commit comments

Comments
 (0)