Just in case, here is the code that sends the user to the login page where he is asked for permissions (one time)
import { msalConfig } from "./authConfig";
...
const msalInstance = new PublicClientApplication(msalConfig);
...
import React from "react";
import { useMsal } from "@azure/msal-react";
import { loginRequest } from "./authConfig";
const LoginButton = () => {
const { instance } = useMsal();
const handleLogin = () => {
instance.loginPopup(loginRequest)
.then(d => console.log("resp: " + JSON.stringify(d)))
.catch(e => {
console.error(e);
});
};
return <button onClick={handleLogin}>Sign in</button>;
};
export const msalConfig = {
auth: {
clientId: "67e81079-efd5-4e35-abde-6d7c61e8bf76",
authority: "https://login.microsoftonline.com/common",
redirectUri: "http://localhost:5174",
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: true,
},
};
export const loginRequest = {
responseMode: "query",
scopes: ["User.Read", "Calendars.ReadWrite"],
};