Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#406 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
32/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
authentication

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
842
Fork
136
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
82

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của stripe/link-cli

Tất cả issue của stripe/link-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.