OAuth Authentication Code Flow Example Using C#/MSAL.NET & MSAL.js?

Siegfried Heintze 1,861 Reputation points
2020-05-28T23:27:36.8+00:00

I've been studying active-directory-b2c-javascript-nodejs-webapi and specifically index.js.

Has anyone translated this node.js script to C#/MSAL.NET? Perhaps there is already an example somewhere?

I was hoping for a single Visual Studio sln file that has the

  1. javascript/MSAL.js front end served with a C#/ASP.NET/MVC project (instead of "npm start" for node.js to serve the javascript) and
  2. a C#/ASP.NET/MVC/MSAL.NET WebAPI instead of this second node.js WebAPI to accept the bearer token. I could not find it at sample-v2-code. Perhaps I missed it?

If there is no such example, perhaps someone could point me to the MSAL.NET functions I might need?

Thanks

Siegfried

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. soumi-MSFT 11,716 Reputation points Microsoft Employee
    2020-05-29T06:27:15.813+00:00

    @Siegfried Heintze , Why would I mix node.js and ASP .Net application in one single solution, when they are two different Server -side languages. For B2C samples, if you plan to use ASP .net core or ASP .net with C# for developing Web Apps or Web APIs, you can check out the following samples:

    ASP .Net Sample: https://github.com/Azure-Samples/active-directory-b2c-dotnet-webapp-and-webapi
    ASP .Net core Sample: https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp

    Both the Samples above uses MSAL for .net and .net core to acquire tokens from B2C.

    Also I would like to share you the link where you can find samples available for B2C with various languages like Asp.Net, ASP .Net core, Node.js, and Python.:
    https://learn.microsoft.com/en-us/azure/active-directory-b2c/code-samples#web-apps-and-apis

    The sample-v2-code that you mentioned, that page contains the application samples for Azure AD and not for Azure AD B2C. Though there is not much difference in the code and the way the libraries are used, but still there are suttle differences like the endpoints etc.

    You can find more details on MSAL (including the various platforms where MSAL is implemented) here: https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-overview

    You would find all the supported languages and the various functions that can be used in with MSAL for the supported language platforms in that same URL.

    Hope this helps.

    Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.


0 additional answers

Sort by: Most helpful