Im following a tutorial from here and trying to enable OpenId Connect using Azure Ad and here's the code that I am trying to add to the Startup.cs file.
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddAzureAd(options => Configuration.Bind("AzureAd", options))
.AddCookie();
But it has red underline for AddAzureAd
and shows this error message:
'AuthenticationBuilder' does not contain a definition for 'AddAzureAd' and no accessible extension method 'AddAzureAd' accepting a first argument of type 'AuthenticationBuilder' could be found (are you missing a using directive or an assembly reference?)
Steps I have tried:
But it doesnt fix the issue. Anyone knows what's the other reason that causes this?
I had the exact same loss of time with something as stupid as not adding the reference. The answer to this question would be along the lines of:
dotnet add package Microsoft.AspNetCore.Authentication.AzureAD.UI --version 2.2.0
Notice that you may have added another reference related to authentication but not the one you are having the problem about.
I had to add a using statement to my Startup file.
using Microsoft.AspNetCore.Authentication;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With