Skip to content

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

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

Open
2 of 9 tasks
mdissel opened this issue May 16, 2025 · 8 comments
Assignees
Labels
sharepoint-developer-support sharepoint-developer-support type:bug-confirmed Confirmed bug, not working as designed / expected. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@mdissel
Copy link

mdissel commented May 16, 2025

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.

@mdissel mdissel added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label May 16, 2025
@Ashlesha-MSFT
Copy link

Hello @mdissel,
Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

@Ashlesha-MSFT Ashlesha-MSFT self-assigned this May 19, 2025
@Ashlesha-MSFT Ashlesha-MSFT added the sharepoint-developer-support sharepoint-developer-support label May 19, 2025
@Ashlesha-MSFT
Copy link

Ashlesha-MSFT commented May 19, 2025

@mdissel,
Thanks for reporting the 'interaction_required' issue with the SPFx web part in Outlook (Web and New). Since it seems to affect only a few users and only in Outlook, could you please share:

  • Detailed Steps to reproduce the issue

  • Any related code (especially where msGraphClientFactory.getClient is used)

  • Any docs or references you're following

This will help us reproduce it on our end and move forward with debugging or escalation.

Appreciate your help!

@mdissel
Copy link
Author

mdissel commented May 19, 2025

Thanks for following this up! As shared in my initial post, the only thing we're trying is to get a msgraph instance from the SPFX framework via executing this code: this.context.msGraphClientFactory.getClient('3'). This is code from the Microsoft SFPX framework. You see in the stacktrace that it's loading MSAL with a redirect to /_forms/spfxsinglesignon.aspx.. but that code is raising an exception 'Redirects are not supported for iframed or brokered applications'.

I'm currently focusing on Outlook WebAccess to make it easier to remove all cookies/session/caching, etc. but nothing helps. It keeps raising the redirect exception.

Do you need more debug info?

Image

@Ashlesha-MSFT
Copy link

@mdissel,
We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it.
Thank you for your patience!

@Ashlesha-MSFT Ashlesha-MSFT added the type:bug-confirmed Confirmed bug, not working as designed / expected. label May 22, 2025
@mdissel
Copy link
Author

mdissel commented May 26, 2025

@Ashlesha-MSFT Any update?

@Ashlesha-MSFT
Copy link

@mdissel,
We have logged the issue with the engineering team; however, there haven’t been any updates from them yet. We’ll continue to follow up and keep you informed as soon as we receive any information.

Thank you for your patience and understanding.

@mdissel
Copy link
Author

mdissel commented Jun 10, 2025

@Ashlesha-MSFT Is there a workaround? can we force a logout/login?

@bvwanroij
Copy link

We have a number of larger 1000+ user sites reporting a similar problem. Can we inform them about a possible resolution planning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sharepoint-developer-support sharepoint-developer-support type:bug-confirmed Confirmed bug, not working as designed / expected. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

3 participants