feat: add use case for token refresh or reset#165
Merged
svenjacobs merged 1 commit intomainfrom Sep 4, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new RefreshTokensOrResetUseCase that provides a convenient way to refresh tokens and automatically reset them when encountering expected OAuth errors like invalid_grant. This complements the existing RunWithTokensOrResetUseCase by offering a standalone token refresh operation with automatic fallback handling.
Key changes:
- Introduces
RefreshTokensOrResetUseCaseclass with similar error handling logic toRunWithTokensOrResetUseCase - Adds comprehensive test coverage for the new use case
- Extracts shared default error constants to a dedicated Constants.kt file
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| RefreshTokensOrResetUseCase.kt | New use case class that wraps token refresh with automatic reset on expected OAuth errors |
| RefreshTokensOrResetUseCaseTest.kt | Complete test suite covering success, expected error reset, and unexpected error scenarios |
| Constants.kt | Shared constant for default OAuth errors list |
| RunWithTokensOrResetUseCase.kt | Updated to use shared constants and added cross-reference documentation |
| RunWithTokensOrResetUseCaseTest.kt | Enhanced test to verify refresh behavior is actually called |
| Client.kt | Added documentation cross-reference to the new use case |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
This PR adds a
RefreshTokensOrResetUseCase, similar toRunWithTokensOrResetUseCase, which callsrefresh()and resets the tokens in case of an expected OAuth error.