Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Device-flow refresh token rejected immediately: 400 "refresh_token is invalid" on first refresh

Aperta
#406 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

Start from the refresh path the report names: AuthResource.refreshToken and createAccessTokenProvider in @stripe/link-cli. Reproduce by running link-cli auth login, moving expires_at into the past in config.json, then link-cli payment-methods list --verbose to capture the POST /device/token request and body. Because the same code path works in 0.25.1, first establish whether the 400 comes from the server for a token the CLI stored correctly, and read the apiFetch retry path in #294. Done means a device-flow refresh token survives the one-hour access-token expiry.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

A refresh token issued by the device flow is rejected immediately. POST https://login.link.com/device/token with grant_type=refresh_token returns 400 {"error":{"message":"refresh_token is invalid"}}, even when the refresh token is brand new and has never been used.

The result: every link-cli session dies one hour after login, when the access token expires. The user must approve a new device login before each purchase.

Reproduction (2026-10-04, ~16:17 UTC)

  1. link-cli auth logout, then link-cli auth login --client-name "Hermes on Oren".
  2. Approve the device login in the Link app. auth status returns authenticated: true, scope userinfo:read payment_methods.agentic, expires_in 3600.
  3. link-cli user-info retrieve and link-cli payment-methods list succeed with the new access token.
  4. About 2 minutes after login, force a refresh (set expires_at in the past in config.json, then run link-cli payment-methods list). Result: Token refresh failed (400): refresh_token is invalid. --verbose shows the request is POST /device/token with grant_type=refresh_token, the stored refresh token (liwlrefresh_...), and client_id=lwlpk_U7Qy7ThG69STZk.
  5. Restore the original expires_at: the access token still works. Only the refresh token is rejected.

The refresh token was used exactly once, from one process on one machine. No other machine or process holds it.

History

  • In August 2026, one login kept working for weeks, so refresh worked then (CLI ~0.10-0.15).
  • Since about 2026-09-25, every refresh fails with this error, on every new login.

Environment

  • @stripe/link-cli 0.19.0. The refresh code path (AuthResource.refreshToken, createAccessTokenProvider) is identical in 0.25.1.
  • Node 26, macOS 26.

Related

  • auth status reports authenticated: true while the refresh token is already unusable, so agents only discover the dead session at payment time.
  • #294: the 401-retry path in apiFetch can re-send a POST. A refresh failure makes that path more likely to be hit.
Lingua principale
TypeScript
Stelle
842
Fork
136
Merge medio
1g 6h
PR unite (30g)
88

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stripe/link-cli

Tutte le issue di stripe/link-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.