You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OAuthAuthorizer drops the refresh token when a refresh response omits refresh_token #312
At main 2a44bfd6f7eca2dc4493ec26892fc48d6ffb0973, OAuthAuthorizer loses the existing refresh token when a successful refresh response omits refresh_token.
A deterministic reproduction uses the public authorizer, InMemoryTokenStorage, and the existing isolated URLProtocol HTTP mocks:
Seed storage with an access token and refreshToken: "old-refresh" for a confidential client.
Trigger a refresh through handleChallenge(statusCode: 401, ...).
Return HTTP 200 from the token endpoint with {"access_token":"new-access","token_type":"Bearer","expires_in":3600} (no replacement refresh token).
Inspect storage: the new access token is present, but refreshToken is nil instead of "old-refresh".
The same loss occurs before proactive refresh: after a successful response with expires_in: 0 and no replacement, prepareAuthorization(for:session:) cannot send the next refresh request because the stored refresh token is absent. This case uses the normal authorization-code configuration with client-secret-basic authentication and no interactive authorization step.
RFC 6749 section 6 makes issuing a replacement refresh token optional. The existing token should remain available when the response omits a replacement; a supplied replacement should replace it.
refreshAccessToken currently calls storeTokenResponse without the token used for that refresh, and storeTokenResponse assigns decoded.refreshToken directly. The reactive path clears storage before the request, so reading storage afterward cannot recover the prior token.
Native Swift Testing reproduces the omission failures on current main. Controls for a supplied replacement, an initial response without a refresh token, and a rejected refresh followed by full token acquisition pass. A local minimal fix passes all five regressions and the full 570-test suite. Verified with Apple Swift 6.3.3 on macOS arm64; HTTP traffic is mocked. Reproduction and fix were prepared with Codex.
I will link the scoped fix after its remaining validation completes.
Activity