Expire session when refresh is unsupported and the access token has expired - #80
Open
germ-mark wants to merge 1 commit into
Open
Expire session when refresh is unsupported and the access token has expired#80germ-mark wants to merge 1 commit into
germ-mark wants to merge 1 commit into
Conversation
oauth4swift 0.6.0's refresh gate throws refreshNotSupported when the server's grant_types_supported excludes refresh_token. The generic catch restored the old access token, so a gated server with expiring tokens became a permanent 401 zombie session. Keep the session while the access token is valid; transition to .expired once it isn't. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 235acff The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Adopts oauth4swift 0.6.0's
OAuth.Errors.refreshNotSupported(germ-network/oauth4swift#58) inAtprotoOAuthAgent.startRefresh. The generic catch restored the previous state and returned the old access token for every refresh error, so a server whosegrant_types_supportedexcludesrefresh_tokencould never reach.expired— once its access token lapsed, the session became a permanent 401 zombie.Now
refreshNotSupportedis caught distinctly: while the access token is still valid the session is preserved as before; once it has expired the agent goes terminal (save stream yields nil, state →.expired,.loggedOutemitted), matching the existing nil-token-state path. Bumps the oauth4swift floor to 0.6.0 (pulls GermConvenience 0.3.0) and re-resolves the demo app's pins to match.Tests: two new
AgentStateMachineTestscover the preserve and terminal paths; full suite passes and the demo app builds against 0.6.0.🤖 Generated with Claude Code