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

aadTokenProviderFactory getToken() does not return anything or throw an error. #9604

Open Circlet-ND opened 3 months ago

Circlet-ND commented 3 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

No response

Describe the bug / error

The code here used to work flawlessly, however for the past weeks I noticed that it keeps on stalling with no response or error message.

const provider = await this.context.aadTokenProviderFactory.getTokenProvider();
await provider.getToken("https://graph.microsoft.com")

Is there any way to fix this or did something change? I've wrapping it in a try catch but there is no error thrown.

Steps to reproduce

  1. Create a SPFX webpart with Graph Permissions specified in the package-solution.json
  2. Deploy app and approve the API permission from SP Admin
  3. Open the webpart

Expected behavior

Webpart should get the token

GrahamMcMynn commented 3 months ago

Hi @Circlet-ND - could you capture a network trace and send it to grahamc at microsoft.com? It would help me investigate the issue. On a test tenant I am not seeing that behavior so would like to figure out why you are seeing that. Thank you!

Circlet-ND commented 2 months ago

Update: I can replicate this issue more consistently if the page that hosts the webpart is loaded in an iFrame.