SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.23k stars 992 forks source link

AADHttpClient awaiting forever #9553

Closed SharePickle closed 4 months ago

SharePickle commented 4 months ago

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

Additional environment details

Describe the bug / error

In Teams Viva Connections on mobile phone (both Android and iOS) anything related to AadHttpClient is not working and forever waiting on getToken method. This includes MSGraphClientV3. For example trying to get anything from Graph API will just be sitting there stuck forever.

No errors in console, no failed network requests, just nothing.

See sample code below:

 const aadHttpClient = await context.aadHttpClientFactory
  .getClient('https://graph.microsoft.com'); // this resolves fine
 const response = await aadHttpClient
  .get(`https://graph.microsoft.com/v1.0/me`, AadHttpClient.configurations.v1); // <== never resolves

IMPORTANT: I'm able to reproduce this outside of Teams (Windows 11 Desktop) using this page (you have to deploy and install an Application Customizer on your site, this page is blank and only loads extensions) https://<tenant>.sharepoint.com/_layouts/15/preload.aspx?mbypass=1&env=WebView If you remove WebView argument then it starts to work without any issues.

While debugging, this bit seems to be never resolving and saving forever pending promise in tokens cache:

image

Steps to reproduce 1 (Teams + Mobile phone)

  1. Open Teams Viva Connections on Mobile phone (iOS or Andriod)
  2. Try any web part that talks to Graph API
  3. It's stuck forever and never resolves (not even rejects).

Steps to reproduce 2 (Browser + Desktop)

  1. Open page https://<tenant>.sharepoint.com/_layouts/15/preload.aspx?mbypass=1&env=WebView
  2. Try any extension that talks to Graph API (it has to be an extension to be able to load on this page)
  3. It's stuck forever and never resolves (not even rejects).

Expected behavior

Graph token succesfully retrieved and Graph API request succeeds.

ghost commented 4 months ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

lucabandMSFT commented 4 months ago

@SharePickle, let's follow up offline. one thing thou: the way you reproed it in the web is wrong and will always fail: when you add env=webView it is a signal for us that we are embedded in Teams. That's where we try to get the token from Teams and not MSAL. in the browser, we are not in Teams so we will always stuck forever.

SharePickle commented 4 months ago

@lucabandMSFT hello, could you please keep the ticket open? Teams issue still not resolved, even if my WebView steps are invalid. Also, how is it possible to debug Teams Viva Connections on Mobile phone, do you guys have any tutorials? I could only find guides on how to test Teams Tab, but not Viva Connections page.

sharepointalist commented 4 months ago

Looks like we have similar issue with any web part using Graph API in mobile SharePoint app and in mobile Teams app (through Viva Connections). Reported by customer and reproduced in multiple tenants.

ghost commented 3 months ago

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues