Forum Discussion

KChawla1404's avatar
KChawla1404
Copper Contributor
Jul 08, 2025

Getting error when trying to get user access token in SPfx solution using MSAL

Referring https://github.com/microsoft/CopilotStudioSamples/tree/main/SharePointSSOComponent

and tried to implement it. Getting error when trying to get user access token using MSAL. The Error

is: Unsafe attempt to initiate navigation for frame with origin 'https://XXXX.sharepoint.com' from frame with URL

'https://login.microsoftonline.com/XXXXXXXX-595d-472c-8248-0dc58f852d61/oaut…04MDZhLTc4NTFlOGEzNWJjNSIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoic2lsZW50In19'.

The frame attempting navigation of the top-level window is sandboxed, but the flag of 'allow-top-navigation'

or 'allow-top-navigation-by-user-activation' is not set.

Issue is intermittent and usually occurs when running on local

 

1 Reply

  • MastOfRoads's avatar
    MastOfRoads
    Iron Contributor

    Update MSAL.js to the latest version in the SPFx solution and ensure that Azure AD applications are registered with the correct API permissions like Sites.ReadWrite.

Resources