Skip to content

feat: add use case for token refresh or reset#165

Merged
svenjacobs merged 1 commit intomainfrom
feat/refresh-or-reset
Sep 4, 2025
Merged

feat: add use case for token refresh or reset#165
svenjacobs merged 1 commit intomainfrom
feat/refresh-or-reset

Conversation

@svenjacobs
Copy link
Owner

This PR adds a RefreshTokensOrResetUseCase, similar to RunWithTokensOrResetUseCase, which calls refresh() and resets the tokens in case of an expected OAuth error.

@svenjacobs svenjacobs self-assigned this Sep 4, 2025
Copilot AI review requested due to automatic review settings September 4, 2025 08:22
@svenjacobs svenjacobs added the enhancement New feature or request label Sep 4, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RefreshTokensOrResetUseCase class with similar error handling logic to RunWithTokensOrResetUseCase
  • 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.

@svenjacobs svenjacobs merged commit 91bfb3d into main Sep 4, 2025
7 checks passed
@svenjacobs svenjacobs deleted the feat/refresh-or-reset branch September 4, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants