I have the following configuration in my ASP.NET Core Web API:
// Adds Microsoft Identity platform (AAD v2.0) support to protect this Api
services.AddMicrosoftIdentityWebApiAuthentication(configuration);
services.AddControllers(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.RequireClaim("email")
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
I have an Angular client application that sends the AuthToken with each request.
Below is my asp.net WEB API controller
[Route("[controller]")]
public class UserController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
//Get User Email ID from Claims
//Get User details from Database
//Return the User Details
...
}
}
In the asp.net WEB API controller, I need to get the Email claim from the Auth Token.
Should the AngularJS application send the AuthToken or IDToken? When do use ID token vs Auth Token?
Update : OpenID Connect is built on top of OAuth2.
WEBAPI: An access_token is useful to call certain APIs in Auth0 (e.g. /userinfo) or an API you define in Auth0.
WEBAPP: An id_token is a JWT and represents the logged in user. It is often used by your app.
CONSOLE/MOBILE APP : A refresh_token (only to be used by a mobile/desktop app) doesn't expire (but is revokable) and it allows you to obtain freshly minted access_tokens and id_token
My question still remains the same? If the webapp or console app requires the claims, should we need AuthToken?