feat: add OAuth device authorization grant flow to nansen login#287
feat: add OAuth device authorization grant flow to nansen login#287shaun-leewei-yang wants to merge 8 commits intomainfrom
Conversation
pr-reviewer Summary📝 4 findings Review completed. Please address the findings below. Findings by Severity
Review effort: 4/5 (Complex) SummaryThis PR adds RFC 8628 OAuth Device Authorization Grant as the new default Findings (1 high, 2 medium, 1 low)
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit e7c84e5.
|
Sorry @shaun-leewei-yang, my claw got a bit overzealous👀 |
References: https://www.notion.so/nansen-ai/nansen-cli-OAuth-Implementation-Plan-31793ded16bd803b96d5fc0d75de5571
Summary
Adds RFC 8628 OAuth Device Authorization Grant as the new default login flow for
nansen login.Changes
src/cli.js—login: device flow as default;--api-keykept as legacy path; help text updatedsrc/api.js— config schema extended withaccessToken/refreshToken/tokenExpiry;NansenAPIsendsAuthorization: Bearerfor OAuth sessions,apikeyfor legacy;_ensureFreshToken()auto-refreshes 60s before expiryauthBaseUrlfor configCHANGELOG.md— new version entryBehaviour
nansen login→ opens browser, shows user code (XXXX-XXXX), polls until approved, saves JWT tokensnansen login --api-key <key>→ unchanged legacy path (CI/scripting)nansen logout→ clears all credentialsKong dependency
Bearer JWT auth on
api.nansen.airequires the Kong JWT plugin (being configured by a separate team). Until then,--api-keycontinues to work. Both paths coexist cleanly — ifaccessTokenis present, use Bearer; else fall back toapikey.