I'm using Azure AD to register my client web app and my web API
I grant access to my client web app
To test this I obtain an access token like this
This gets me a code
Now I get the access token
But when I try this call to my securized controller
In my web API I have this in appsettings.json
"AzureAd": {
"Authority": "https://login.microsoftonline.com/tenantID",
"Audience": "https://fulcrum.es/planificadorAPI"
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services
.AddAuthentication(options=>
{
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
}
).AddJwtBearer(options => Configuration.Bind("AzureAd", options));
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app
.UseDeveloperExceptionPage();
}
app
.Map("/api", api =>
{
api.UseCors(policy =>
{
policy.AllowAnyHeader();
policy.AllowAnyMethod();
policy.AllowAnyOrigin();
})
.UseAuthentication()
.UseMvc();
})
.Run(context => context.Response.WriteAsync("FysegPlanner webAPI started"));
}
In Controller
namespace api.Controllers
{
[Authorize]
[Route("proyectos")]
[HttpGet]
[Route("")]
public async Task<IActionResult> Get()
{
var getAllResponse = await mediator.Send(new ListAll());
return Ok(getAllResponse);
}
Any idea, please?
Thanks