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

SPFx causes triple page reload when calling custom API with pending permission grant

Open jbolliet-jint opened this issue 1 year ago • 7 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
  • [ ] 💥 Microsoft Edge
  • [x] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version: 137.0.7151.69 (Official Build) (arm64)
  • SPFx version: 1.21.1
  • Node.js version: 22.16.0

Describe the bug / error

Issue Summary We have encountered a critical issue affecting multiple tenants since May 2025. Whenever a SharePoint Framework (SPFx) package attempts to retrieve a token from a custom API for which a permission is still pending (neither approved nor rejected), the SharePoint page reloads three times automatically. This behavior is repeated just once for a period of between 2 and 5 minutes (I don't know exactly, I guess there's a cache) and then refreshes 3 times again on the next navigation.

Image

This behavior occurs systematically and seems to be introduced after the recent change described in the following article: Changes on SharePoint Framework (SPFx) permission grants in Microsoft Entra ID.

Technical Observation Before each page reload, the following request is made: GET https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize And include the following payload:

client_id=08e18876-6177-487e-b8b5-cf950c1e598c
scope={application_id_uri}%2F.default%20openid%20profile%20offline_access
[...]

This request results in an HTTP 302 redirect with the following header: Location: https://{tenant}.sharepoint.com/_forms/spfxsinglesignon.aspx And includes the following error details in the query string on this Location:

error=invalid_client
error_description=AADSTS650057: Invalid resource. 
The client has requested access to a resource which is not listed in the requested permissions in the client’s application registration.
Client app ID: 08e18876-6177-487e-b8b5-cf950c1e598c (SharePoint Online Web Client Extensibility)
Resource value from request: {application_id_uri}
[...]

Impact

  • This issue affects several dozen of our clients.
  • Tens of thousands of users are impacted by the page reload loop.
  • It severely disrupts the user experience and functionality of our SPFx solutions.

Steps to reproduce

  1. Create a basic HelloWorld SPFx project of type ApplicationCustomizer using SPFx version 1.21.1.
  2. In the package-solution.json file, add a custom API permission under the webApiPermissionRequests section (e.g., for a custom Entra ID app).
  3. In the HelloWorldApplicationCustomizer.ts file, retrieve a token for the custom API using the following code:
export default class HelloWorldApplicationCustomizer extends BaseApplicationCustomizer<IHelloWorldApplicationCustomizerProperties> {
  public async onInit(): Promise<void> {
    Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);

    const tokenProvider = await this.context.aadTokenProviderFactory.getTokenProvider();
    const token = await tokenProvider.getToken("{application_id_uri}");
  }
}
  1. Build and package the solution.
  2. Upload the .sppkg file to the App Catalog, deploy it, and ensure it is enabled by default.
  3. Important: Do not approve or reject the API permission request in the SharePoint Admin Center. Image
  4. Navigate to a SharePoint page and observe the behavior: the page refreshes three times automatically each time getToken() is called.

Expected behavior

The page should remain stable and handle the permission request gracefully without causing reloads, even if the permission is pending.

jbolliet-jint avatar Jun 09 '25 21:06 jbolliet-jint

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

Amey-MSFT avatar Jun 10 '25 04:06 Amey-MSFT

Hello @BollietMZK, 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!

Amey-MSFT avatar Jun 10 '25 13:06 Amey-MSFT

Hello, I am following up regarding the ticket opened on June 9 and confirmed by your teams as a reproducible bug on June 10, related to the triple refresh behavior in SharePoint. To date, we have not received any update on the progress of the resolution. This issue is still impacting several tens of thousands of users and is causing significant disruptions in daily use of the platform. Do you have any news on the fix?

jbolliet-jint avatar Nov 20 '25 15:11 jbolliet-jint

@jbolliet-mozzaik365, After further review, the engineering team has determined that the triple page reload behavior you observed when calling getToken() for a pending API permission is currently by design in SPFx.

Ashlesha-MSFT avatar Nov 21 '25 07:11 Ashlesha-MSFT

Thank you for your update.

However, I must admit that this explanation is difficult to accept as-is. I do not understand in what way a triple page reload can be considered an intentional SPFx feature simply because SharePoint cannot handle an API permission that is pending approval.

From a user-experience and technical standpoint, this behavior appears much more like a defect than a design choice. It also continues to impact tens of thousands of users on our side.

Could you please provide:

  • a detailed explanation of why this behavior would be “by design”,
  • what the expected workflow is in such a scenario, and
  • whether the engineering team plans to reconsider this behavior or provide a more appropriate handling mechanism?

Thank you in advance for your clarification.

jbolliet-jint avatar Nov 21 '25 07:11 jbolliet-jint

Hello @Ashlesha-MSFT Do you have any news?

jbolliet-jint avatar Apr 13 '26 18:04 jbolliet-jint

@jbolliet-mozzaik365, Already have tagged to engineering team and this is what they said - Tehcnically currently by design.

Ashlesha-MSFT avatar Apr 14 '26 04:04 Ashlesha-MSFT