How to create a custom Logout component in React with MSAL2Provider

Tony Lockhart 106 Reputation points
2022-06-30T05:16:42.193+00:00

I am using the React Login MGT component (see snippet Below) and MSAL2Provider to log users into my Active Directory application, which works well. However, I have a requirement to create a custom logout button, which logs the current user out of the application, without user interaction. I was able to find documentation on creating a custom component using the MSALProvider, but I would like to use MSAL2Provider, since it is more secure and that is what I'm currently using. Can anyone point me to any documentation on creating a custom login/logout component with React and MSAL2Provider?

 Providers.globalProvider = new Msal2Provider({  
  clientId: "client-id"  
});  
  
<Login  
             loginCompleted={(event) => {mgtSSOLoggedIn(event)}}  
             loginFailed={(event) => {mgtSSOFailed(event)}}  
/>  
  
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mehtab Siddique (MINDTREE LIMITED) 971 Reputation points
    2022-07-01T02:10:19.577+00:00

    Hi @Tony Lockhart , For User Login/Logout component in MSAL2Provider check the following:

    216732-image.png

    For customizing the Login component please refer: https://learn.microsoft.com/en-us/graph/toolkit/components/login

    Info on Migration from Migrating from MSAL Provider to MSAL2 Provider: https://learn.microsoft.com/en-us/graph/toolkit/providers/msal2#migrating-from-msal-provider-to-msal2-provider

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.