Skip to content

fix: refresh endpoint uses refresh-token header, not body#7

Merged
ooswald merged 1 commit into
mainfrom
fix-refresh-header
May 11, 2026
Merged

fix: refresh endpoint uses refresh-token header, not body#7
ooswald merged 1 commit into
mainfrom
fix-refresh-header

Conversation

@ooswald
Copy link
Copy Markdown
Owner

@ooswald ooswald commented May 11, 2026

What

`tryRefresh()` was POSTing the refresh JWT in a JSON body field. The Flappie backend reads it from a `refresh-token` HTTP header — body submission returns a pydantic 422 (`missing header`) which the try/catch in `tryRefresh()` swallowed silently. End user effect: every ~12h the access token expires and the next call returns 401 to the caller with no automatic recovery, so it looks like `flappie login` is needed on a daily basis.

Fix

Send the token as a `refresh-token` HTTP header. Confirmed against the live API and via the Dart disassembly (`pp+0x9180 "refresh-token"`).

Tested locally: `flappie whoami` recovers without re-login when the access token is expired.

Also in this PR

  • `CLOUD_API.md` + `openapi.yaml` updated to document the header-based contract.
  • Version bump 0.5.0 → 0.5.1.
  • CHANGELOG entry under `[0.5.1]`.

After merge

This will be the first end-to-end test of the release automation: push `v0.5.1` tag → `.github/workflows/release.yml` runs → `npm publish --provenance` via OIDC → GitHub Release page auto-created.

tryRefresh() was POSTing the refresh JWT in a JSON body field, which the
backend rejects with a pydantic 422 ("missing header"). The error was
swallowed by the try/catch, so callers saw the original 401 propagated
through with no indication that the refresh attempt had even happened -
effectively treating every access-token expiry (~12h) as a forced
re-login.

Fixed by sending the token as a `refresh-token` HTTP header, matching
what the Flutter app does (confirmed via the reverse-engineered Dart
disassembly: pp+0x9180 "refresh-token"). With this fix the session
survives until the refresh token itself expires, ~30 days.

Also updates CLOUD_API.md and openapi.yaml to document the actual
header-based contract. Bumps version to 0.5.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ooswald ooswald merged commit e02b803 into main May 11, 2026
1 check passed
@ooswald ooswald deleted the fix-refresh-header branch May 11, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant