feat: add token refresh lifecycle callbacks to CalProvider#25203
Merged
Ryukemeister merged 3 commits intomainfrom Jan 27, 2026
Merged
feat: add token refresh lifecycle callbacks to CalProvider#25203Ryukemeister merged 3 commits intomainfrom
Ryukemeister merged 3 commits intomainfrom
Conversation
Add three new optional callbacks to CalProvider that enable users to react during the access token refresh lifecycle: - onTokenRefreshStart: Called when token refresh begins - onTokenRefreshSuccess: Called when token refresh succeeds - onTokenRefreshError: Called when token refresh fails with error message These callbacks are invoked in both token refresh locations: 1. Response interceptor (when API returns 498 status) 2. Initial access token validation The callbacks are properly passed through the component hierarchy: CalProvider -> BaseCalProvider -> useOAuthFlow hook Co-Authored-By: morgan@cal.com <morgan@cal.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
Contributor
|
This PR has been closed due to inactivity. Please feel free to reopen it if you'd like to continue the work. |
Ryukemeister
approved these changes
Jan 27, 2026
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.
What does this PR do?
Adds three new optional callback props to
CalProviderthat enable users to react during the OAuth access token refresh lifecycle:onTokenRefreshStart: Called when token refresh beginsonTokenRefreshSuccess: Called when token refresh succeedsonTokenRefreshError: Called when token refresh fails (receives error message as parameter)These callbacks are invoked in both token refresh locations:
The callbacks are properly threaded through the component hierarchy:
CalProvider→BaseCalProvider→useOAuthFlowhook.Related:
Visual Demo
N/A - This is a programmatic API change with no visual component.
Mandatory Tasks
How should this be tested?
Manual testing approach:
Trigger a token refresh by:
Verify the callbacks are invoked in the correct order:
onTokenRefreshStartshould fire firstonTokenRefreshSuccessoronTokenRefreshErrorshould fire afteronSuccess/onErrorcallbacks should still workExpected behavior:
Important Review Points
Removed try-catch block (line 75-97 in useOAuthFlow.ts): I removed an empty try-catch block that wrapped the
http.get()call. Since errors are already handled in the.catch()method, this should be safe, but please verify there are no edge cases where synchronous errors could occur.Removed eslint-disable comment (line 2 in useOAuthFlow.ts): The
// eslint-disable-next-line no-restricted-importscomment for lodash was accidentally removed. This may need to be restored if it causes linting issues.No automated tests: This PR does not include tests for the new callbacks. Consider whether integration tests should be added before merging.
Dependency arrays: The new callbacks are added to useEffect dependency arrays. If consumers pass unstable callback references (not memoized), this could cause unnecessary re-renders.
Checklist