Created
May 12, 2024 09:27
-
-
Save LauraKokkarinen/000e3f2e9b733728d3e3798a2874d136 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserRouter } from "react-router-dom"; | |
import { MsalAuthenticationTemplate, MsalProvider } from "@azure/msal-react"; | |
import { PublicClientApplication, InteractionType } from '@azure/msal-browser'; | |
import { loginRequest } from "./msalConfig"; | |
interface AppProps { | |
instance: PublicClientApplication; | |
} | |
const authRequest = { | |
...loginRequest | |
}; | |
/** | |
* All parts of the application that require authentication must be wrapped in the MsalProvider component. | |
* The MsalAuthenticationTemplate component will render its children if a user is authenticated or attempt to sign a user in. | |
*/ | |
const App = ({ instance }: AppProps) => { | |
return ( | |
<BrowserRouter> | |
<MsalProvider instance={instance}> | |
<MsalAuthenticationTemplate interactionType={InteractionType.Redirect} authenticationRequest={authRequest}> | |
{/* Content that is visible only to authenticated users */} | |
</MsalAuthenticationTemplate> | |
</MsalProvider> | |
</BrowserRouter> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment