question

SiegfriedHeintze-9929 avatar image
0 Votes"
SiegfriedHeintze-9929 asked ·

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

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






azure-active-directory
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

soumi-MSFT avatar image
0 Votes"
soumi-MSFT answered ·

@SiegfriedHeintze-9929, 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://docs.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://docs.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.

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes -- this helped a lot. I'm pleased that I have it running.

I had to readup on OpenID Connect and I realized OpenID Connect was more secure than OAuth Authorization Code Flow.

I see I should have have tried to make 4-2-B2C work instead because I wanted .NET Core instead of .NET Framework... I see that this 4-2-B2C sample is part of a sequence, however. Should I be able to jump into the middle of the sequence with out doing 4-1-MyOrg first?


0 Votes 0 · ·