Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
311fc3f
Add a bakground ssoSilent call after interactive calls, with telemetry
sameerag Jan 19, 2026
632c393
update the interactive APIs
sameerag Jan 19, 2026
0a2f5e1
Change files
sameerag Jan 19, 2026
eb8df76
Update change/@azure-msal-common-461989e8-10b5-48f1-91dd-836248c3fce6…
sameerag Jan 19, 2026
ef600d9
Update change/@azure-msal-browser-440d27b3-88ff-459d-883e-a675b66d797…
sameerag Jan 19, 2026
fa1c809
Background SSO calls (#8253)
Copilot Jan 19, 2026
b0eac1a
Update lib/msal-browser/src/controllers/StandardController.ts
sameerag Jan 19, 2026
4565ab7
Update lib/msal-browser/src/config/Configuration.ts
sameerag Jan 19, 2026
f1fff9d
Update change/@azure-msal-browser-440d27b3-88ff-459d-883e-a675b66d797…
sameerag Jan 19, 2026
b14dbe8
Update change/@azure-msal-common-461989e8-10b5-48f1-91dd-836248c3fce6…
sameerag Jan 19, 2026
7626e80
Limit the sso to session refresh
sameerag Jan 19, 2026
e9a32f7
update apiExtractor
sameerag Jan 20, 2026
7f283d7
Update lib/msal-browser/src/config/Configuration.ts
sameerag Jan 20, 2026
64de352
Update lib/msal-browser/src/config/Configuration.ts
sameerag Jan 20, 2026
4ee54c0
Update names
sameerag Jan 20, 2026
1e24dcb
Update apiExtractor for msal-common
sameerag Jan 20, 2026
827a6ff
Merge branch 'dev' into sso-post-interaction
sameerag Jan 20, 2026
e0f6b03
Merge branch 'dev' into sso-post-interaction
sameerag Feb 8, 2026
cd804d1
Update correlationId - change it to be a different one
sameerag Feb 9, 2026
28cbf36
Address feedback
sameerag Feb 9, 2026
d29ef3d
Merge branch 'dev' into sso-post-interaction
konstantin-msft Feb 10, 2026
6e7f446
Rename appropriately
sameerag Feb 12, 2026
03a70d4
Rename config
sameerag Feb 17, 2026
4e6c400
Merge branch 'dev' into sso-post-interaction
sameerag Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add a background ssoSilent call after interactive calls, with telemetry",
"packageName": "@azure/msal-browser",
"email": "sameera.gajjarapu@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add a background ssoSilent call after interactive calls, with telemetry",
"packageName": "@azure/msal-common",
"email": "sameera.gajjarapu@microsoft.com",
"dependentChangeType": "patch"
}
7 changes: 7 additions & 0 deletions lib/msal-browser/src/config/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export type BrowserAuthOptions = {
* @deprecated This flag is deprecated and will be removed in the next major version where all extra query params will be encoded by default.
*/
encodeExtraQueryParams?: boolean;
/**
* If set to true, MSAL will make a background ssoSilent call after successful interactive authentication
* (acquireTokenPopup, handleRedirectPromise) to refresh tokens silently.
* This is a boolean flag and defaults to false if not specified.
*/
enableBackgroundSSO?: boolean;
};

/** @internal */
Expand Down Expand Up @@ -314,6 +320,7 @@ export function buildConfiguration(
supportsNestedAppAuth: false,
instanceAware: false,
encodeExtraQueryParams: false,
enableBackgroundSSO: false,
};

// Default cache options for browser
Expand Down
79 changes: 79 additions & 0 deletions lib/msal-browser/src/controllers/StandardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ export class StandardController implements IController {
undefined,
result.account
);

// Fire-and-forget ssoSilent to refresh tokens in background
this.bkgdSsoSilent(result, "handleRedirectPromise");
} else {
/*
* Instrument an event only if an error code is set. Otherwise, discard it when the redirect response
Expand Down Expand Up @@ -930,6 +933,10 @@ export class StandardController implements IController {
undefined,
result.account
);

// Fire-and-forget ssoSilent to refresh tokens in background
this.bkgdSsoSilent(result, "acquireTokenPopup");

return result;
})
.catch((e: Error) => {
Expand Down Expand Up @@ -984,6 +991,78 @@ export class StandardController implements IController {
visibilityChangeCount: 1,
});
}

/**
* Fire-and-forget ssoSilent call to refresh tokens in the background.
* This method does not block the caller and tracks telemetry for success/failure.
* This method only executes if enableBackgroundSSO is set to true in the cache configuration.
* @param result - The authentication result from the parent operation
* @param parentApiId - The API ID of the parent operation for logging purposes
*/
private bkgdSsoSilent(
result: AuthenticationResult,
parentApiId: string
): void {
// Check if background SSO is enabled
if (!this.config.auth.enableBackgroundSSO) {
return;
}

const correlationId = createNewGuid();
const bgSsoSilentMeasurement = this.performanceClient.startMeasurement(
PerformanceEvents.BackgroundSsoSilent,
correlationId
);
bgSsoSilentMeasurement.add({
parentApiId: parentApiId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're calling this ApiId we should use ApiId

});

this.logger.verbose(
`Background ssoSilent initiated after ${parentApiId}`,
correlationId
);

/*
* Use setTimeout to ensure this runs in a separate macrotask after the current call stack completes
* This ensures the result is returned to the caller before ssoSilent starts and doesn't affect performance
*/
setTimeout(() => {
const ssoSilentRequest: SsoSilentRequest = {
account: result.account,
correlationId: correlationId,
};

this.ssoSilent(ssoSilentRequest)
.then((ssoResult) => {
this.logger.verbose(
`Background ssoSilent completed successfully after ${parentApiId}`,
correlationId
);
bgSsoSilentMeasurement.end(
{
success: true,
accessTokenSize: ssoResult.accessToken.length,
idTokenSize: ssoResult.idToken.length,
},
undefined,
ssoResult.account
);
})
.catch((error: Error) => {
this.logger.warning(
`Background ssoSilent failed after ${parentApiId}: ${error.message}`,
correlationId
);
bgSsoSilentMeasurement.end(
{
success: false,
},
error,
result.account
);
});
}, 0);
}
// #endregion

// #region Silent Flow
Expand Down
Loading