Adding logic to retry with regular RT, if available, when BART redemp…#1648
Open
Adding logic to retry with regular RT, if available, when BART redemp…#1648
Conversation
…ttps://github.com/AzureAD/microsoft-authentication-library-common-for-objc into ameyapat/add-retry-logic-when-bart-redemption-fails * 'ameyapat/add-retry-logic-when-bart-redemption-fails' of https://github.com/AzureAD/microsoft-authentication-library-common-for-objc: Remove code not needed. Fix build error: multiple methods named 'length' found [-Wstrict-selector-match] on /src/oauth2/MSIDOauth2Factory.m:422:17
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a retry mechanism to fallback to regular refresh tokens when Bound App Refresh Token (BART) redemption fails. When a BART redemption attempt fails with a non-recoverable error, the code now sets a flag to skip BART lookup on retry and attempts to use a regular refresh token if available in the cache.
Key Changes:
- Added a new error code
MSIDErrorBoundAppRefreshTokenRedemptionErrorto identify BART redemption failures - Implemented retry logic in
MSIDSilentControllerto automatically retry token acquisition with regular RTs when BART fails - Added
shouldSkipBoundAppRefreshTokenUsageflag to control BART token lookup during retry attempts - Enhanced telemetry to log BART redemption failures with "BART-RED-FAIL" messages
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| IdentityCore/src/MSIDError.h | Added new error code MSIDErrorBoundAppRefreshTokenRedemptionError (-51120) for BART redemption failures |
| IdentityCore/src/MSIDError.m | Added error string mapping for the new BART redemption error code |
| IdentityCore/src/requests/MSIDSilentTokenRequest.h | Added shouldSkipBoundAppRefreshTokenUsage property to control retry behavior |
| IdentityCore/src/requests/MSIDSilentTokenRequest.m | Implemented logic to detect BART failures, set skip flag, log telemetry, and return redemption error |
| IdentityCore/src/requests/sdk/msal/MSIDDefaultSilentTokenRequest.m | Propagates skip flag to cache accessor when retrieving family and app refresh tokens |
| IdentityCore/src/controllers/MSIDSilentController.m | Added retry logic to detect BART redemption errors and automatically retry with regular RTs |
| IdentityCore/src/cache/accessor/MSIDDefaultTokenCacheAccessor.h | Added shouldSkipBoundAppRefreshTokenLookup property to control BART token queries |
| IdentityCore/src/cache/accessor/MSIDDefaultTokenCacheAccessor.m | Modified token lookup methods to skip BART tokens when flag is set |
| IdentityCore/tests/mocks/MSIDTestTokenRequestProvider.h/m | Modified to cache and return the same silent request instance for retry testing |
| IdentityCore/tests/mocks/MSIDTestSilentTokenRequest.h/m | Exposed properties to allow test configuration |
| IdentityCore/tests/mocks/MSIDTestBoundAppRefreshTokenRequest.h/m | New test mock to simulate BART redemption failure and retry scenarios |
| IdentityCore/tests/integration/ios/MSIDDefaultSilentTokenRequestTests.m | Added test to verify BART redemption error reporting and telemetry |
| IdentityCore/tests/integration/MSIDSilentControllerIntegrationTests.m | Added integration test to verify complete retry flow from controller level |
| IdentityCore/IdentityCore.xcodeproj/project.pbxproj | Added new test mock files to the Xcode project |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-fails * dev: Add AI agent instructions files for this repository. (#1626) Merge release 1.19.1 into dev (#1693) Split broker common submodule check into separate stages (#1668) [major][feature]: Add request execution flow logger (#1655) # Conflicts: # IdentityCore/src/requests/MSIDSilentTokenRequest.m # IdentityCore/tests/integration/ios/MSIDDefaultSilentTokenRequestTests.m # changelog.txt
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.
…tion fails
Proposed changes
When a bound app refresh token redemption fails, we should retry with a regular refresh token if it is available in the cache.
This PR aims to add retry logic
Type of change
Risk
Additional information