-
Notifications
You must be signed in to change notification settings - Fork 36
Adding logic to retry with regular RT, if available, when BART redemp… #1648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
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
There was a problem hiding this 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 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 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…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