Repository navigation
Fix CLI token refresh by preserving OAuth port across sessions - #64
Merged
Merged
Conversation
The OAuth client_id for loopback clients includes the redirect URI port. During login, a random free port is used (e.g. 54321), but when restoring sessions, port 0 was hardcoded. This client_id mismatch caused the PDS to reject token refresh requests after the access token expired (~1 hour), making users appear logged out. Now the port from login is stored in session.json and reused for session restoration, keeping the client_id consistent so refresh tokens work. Also improves the error message when sessions expire to show the user's handle and suggest re-login instead of the generic "not logged in" message.
Pass authInfo from requireAgent() into getAgent() so the session file is only read once per command invocation.
Owner
|
ah fantastic! this has been bugging me for a while. thanks for tracking it down |
Owner
|
oh could you run formatting to let CI pass? |
Contributor
Author
|
Yeah will do! Weird I thought all tests passed but perhaps I forgot the formatter |
Contributor
Author
|
I think it should be ok now? |
Owner
|
perfect, thanks! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sb logininsession.jsonNodeOAuthClientfor session restoration, so theclient_idstays consistent and token refresh works after the access token expires (~1 hour)Fixes #63
Changes
cli/src/lib/config.ts— Add optionaloauthPortfield toAuthInfocli/src/lib/auth.ts—login(): Save the port in auth infogetAgent(): Use stored port (falls back to 0 for existing sessions)requireAgent(): Show "Session expired" with handle instead of generic "Not logged in"Test plan
sb login, wait >1 hour, runsb cards— should work without re-login~/.config/skyboard/session.jsonnow containsoauthPortoauthPort) gracefully fall back to port 0