SharePoint / SharePoint/sp-dev-docs

SPFX getClient via msGraphClientFactory is failing with Application requested a user session which does not exist exception

Open
#10,269 9 comments 1 reaction 1 assignee View on GitHub

@Ashlesha-MSFT is already working on this.

Since May 19, 2025.

sharepoint-developer-support type:bug-confirmed type:bug-suspected
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details
  • browser MS Edge
  • SPFx version 1.20
  • Node.js version 18
  • Outlook New 1.2025.506.300
  • WebView2 version 136.3.3240.64
Describe the bug / error

In our SPFX webpart we are using this code to get a MS Graph client. For a small number of users (not all) this results in an exception 'interaction required' when the webpart is loaded inside Outlook New and/or Outlook webaccess. The problem does not occur when the same user is loading the webpart in a browser when the webpart is loaded in a sharepoint page.

The problem is occuring on multiple different tenants, but only with a few users....

this.context.msGraphClientFactory
      .getClient('3')
      .then((client: MSGraphClientV3): void => {
        // use MSGraphClient here
      });

interaction_required: AADSTS160021: Application requested a user session which does not exist. Trace ID: 121500f7-c641-4070-b9f3-746f72221f00 Correlation ID: 7cd2050f-882d-4de2-a2da-678bfbec6d67

The webpart is using the following URL in Outlook (Web Access) in the iframe:
https://XXXXX.sharepoint.com/_layouts/15/TeamsLogon.aspx?SPFX=true&dest=/_layouts/15/teamshostedapp.aspx%3Fteams%26personal%26componentId=XXXXXXX3%26forceLocale=en-US%26theme=default
The following exception is logged:

BrowserAuthError: redirect_in_iframe: Redirects are not supported for iframed or brokered applications. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs.
    at si (chunk.861_none_8c7b00678350b9a90181.js:2:51524)
    at chunk.861_none_8c7b00678350b9a90181.js:2:55011
    at Fi (chunk.861_none_8c7b00678350b9a90181.js:2:55018)
    at Bo.acquireTokenRedirect (chunk.861_none_8c7b00678350b9a90181.js:2:216634)
    at Bo.loginRedirect (chunk.861_none_8c7b00678350b9a90181.js:2:230148)
    at qo.loginRedirect (chunk.861_none_8c7b00678350b9a90181.js:2:249393)
    at e._loginRedirect (chunk.msalLegacyBrowser_none_bb75d4e042ae17936bcb.js:3:18708)
    at chunk.msalLegacyBrowser_none_bb75d4e042ae17936bcb.js:3:15117
    at async Proxy.<anonymous> (XXXXXXX-web-part_286c00a2c7e4153fc1db.js:22:1328)
    at async XXXXXXXX-web-part_286c00a2c7e4153fc1db.js:30:2708
Expected behavior

this.context.msGraphClientFactory.getClient('3') should return client with a valid token.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.