Skip to content

Conversation

@ameyapat
Copy link
Contributor

@ameyapat ameyapat commented Jan 8, 2026

…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

  • Feature work
  • Bug fix
  • Documentation
  • Engineering change
  • Test
  • Logging/Telemetry

Risk

  • High – Errors could cause MAJOR regression of many scenarios. (Example: new large features or high level infrastructure changes)
  • Medium – Errors could cause regression of 1 or more scenarios. (Example: somewhat complex bug fixes, small new features)
  • Small – No issues are expected. (Example: Very small bug fixes, string changes, or configuration settings changes)

Additional information

@ameyapat ameyapat requested a review from a team as a code owner January 8, 2026 03:57
…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
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 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 MSIDErrorBoundAppRefreshTokenRedemptionError to identify BART redemption failures
  • Implemented retry logic in MSIDSilentController to automatically retry token acquisition with regular RTs when BART fails
  • Added shouldSkipBoundAppRefreshTokenUsage flag 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants