microsoft-graph-toolkit

Login combination betwen c# and js Msal-provider


Question: How can i use only 1 msal-provider on my mvc website currently using mgt-msal-provider through the toolkit, and Owin authentication for when i need to send an mail. tho this ends with me having 2 login buttons, which is rather inconvenient.

Request.GetOwinContext().Authentication.Challenge(
  new AuthenticationProperties { RedirectUri = "/" },
  OpenIdConnectAuthenticationDefaults.AuthenticationType);

and

<mgt-msal-provider client-id=@appId
  login-type="popup"
  scopes="user.read,people.read,people.read.all,contacts.read,user.read.all"
  authority=@authority></mgt-msal-provider>

im using the Owin one because i havent found a way to send a custom email with the toolkit, but i can do that through the c# Microsoft.Graph library

my 2 different login buttons


Solution

  • In this scenario, you could leverage the proxy provider. The proxy provider can proxy all calls to the Microsoft Graph through your backend so you can leverage your Owin authentication for accessing the graph. This will allow users to authenticate only once but still leverage the toolkit components on your front end.

    Take a look at this ASP.NET MVC sample. There is also an ASP.NET Core sample you could use.