Search code examples
asp.net-web-apiangular2-servicesazure-ad-b2c

How to authenticate and authorize the token from Angular 2 web app using Azure ad b2c at ASP.net Web API?


I am using angular 2 at client side and I want to allow the consumers to login using the social accounts like Google, Facebook etc.

For that I am using the Azure ad b2c.

I want to secure the Web API with a token from the angular 2 web app.

How can I achieve that?

I have tried msal library (preview) in Angular 2 for authenticating the user using Azure ad b2c. But I am not able to authorize the token at Web API.


Solution

  • See this Angular 4 example w/ MSAL.js.

    Also, this blog post is a good guide for securing Web API. There's also a good sample project on GitHub: An ASP.NET Core 2.0 web API with Azure AD B2C.