sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

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

Open Circlet-ND opened this issue 1 year ago • 1 comments

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
  • [X] 💥 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

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

Circlet-ND avatar Mar 26 '24 00:03 Circlet-ND

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!

GrahamMcMynn avatar Mar 26 '24 15:03 GrahamMcMynn

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

Circlet-ND avatar Apr 09 '24 06:04 Circlet-ND

Hello @Circlet-ND, Thank you for bringing this issue to our attention. Could you please confirm if the issue still persists for you?

Amey-MSFT avatar Jun 23 '25 05:06 Amey-MSFT

We are closing this issue for now. If the problem persists, feel free to reopen it or open a new one.

Amey-MSFT avatar Jul 07 '25 10:07 Amey-MSFT