Azure AD B2C - Using access token returned from sign in flow to secure the rest web API

Viewed 47

I am using Azure B2C in my react SPA to sign in the user with external identity providers e.g. Google and Facebook. I have some .net core web API that needs to be called by signed-in users only. I have followed Azure documents for my scenario. As per the docs, I need to register another AD B2C application for web API security and my client app needs to acquire the token with the scope defined in the server-side AD app and pass that token while calling the web API.

Why can't I use the same access token received from azure AD B2C as part of the sign-in flow to pass it to my web API and validate it on the server side to secure the Web API? In that case, I don't need to create another server-side AD application for securing the API.

1 Answers

You can, but it’s simply against the protocol spec. Each client needs to be registered and have a unique client Id/AppId.

Plus if you do it with one App Registration, your logs would never differentiate access to your front end vs access to your api.

Related