Skip to content

Authentication in Single Page Application

If you are writing a single page application deployed outside SharePoint it is recommended to use the MSAL client. You can find further details on the settings in the MSAL docs. You will need to ensure that you grant the permissions required to the application you are trying to use.

import { MsalClientSetup  } from "@pnp/msaljsclient";
import { graph } from "@pnp/graph/presets/all";

    graph: {
        fetchClientFactory: MsalClientSetup({
            auth: {
                authority: "",
                clientId: "00000000-0000-0000-0000-000000000000",
                redirectUri: "{your redirect uri}",
            cache: {
                cacheLocation: "sessionStorage",
        }, ["email", "Files.Read.All", "User.Read.All"]),

const data = await;