Closed markti closed 4 years ago
use AzureADDefaults.BearerAuthenticationScheme
, not AzureADDefaults.AuthenticationScheme
. I found that on one of the other samples, I think.
Upgrading this sample to use the AzureAD.UI works for me on the API side, but, the logged-in MVC app is unable to get a bearer token, always throwing AdalSilentTokenAcquisitionException
. (cf #36)
Closing as we are archiving this sample.
The newer one can be found at: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/4-WebApp-your-API
This example uses some extension methods defined in AzureAdServiceCollectionExtensions. That [are rather hacky] and made available in Microsoft.AspNetCore.Authentication.AzureAD.UI. However, when I use the same extension method in Microsoft.AspNetCore.Authentication.AzureAD.UI I get the following error:
I tried getting it to work by following the example provided here:
https://github.com/aspnet/AspNetCore/tree/master/src/Azure/AzureAD/samples/AzureADSample
This uses the following code to AddAuthentication:
services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureAD(options => Configuration.GetSection("AzureAD").Bind(options));
However, I get the following error:
The above error doesn't make much sense to me as the TodoListService Application is configured with "https://localhost:44351" Redirect URI (reply URL).
Using this approach gives me the following error again:
When I change the sample to:
services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureADBearer(options => Configuration.Bind("AzureAd", options));
I get the following error:
This differs from this example which currently does this:
services.AddAuthentication(sharedOptions => { sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));
However, this current example uses an internal version of the AdAzureAdBearer token (notice the lowercase 'd' in 'Ad'. Whereas the seemingly official version of the extension method uses AdAzureAD()