Open vvolodin opened 2 years ago
I've used overloads that specify authentication scheme explicitly and it helped. But I still wonder if I'm missing something that will come up later.
In Startup.cs, you need to have services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
but you should just have services.AddAuthentication()
for the cookies. Are you using 1.20 (latest version)?
Which version of Microsoft Identity Web are you using? 1.12.0
Where is the issue?
Is this a new or an existing app? Existing
Repro
or
Expected behavior Return auth result
Actual behavior Null reference exception
Possible solution I've debugged a previous version of the library I've been using and
GetAccessTokenForUserAsync
worked correctly as its documentation stated - from the xml docs aboutauthenticationScheme
param: "Authentication scheme. If null, will use OpenIdConnectDefault.AuthenticationScheme if called from a web app, and JwtBearerDefault.AuthenticationScheme if called from a web API." But now theGetEffectiveAuthenticationScheme
returns "Cookies" instead - my main authentication scheme causingGetAccessTokenForUserAsync
to throw null reference because there's no client ID or secret defined in my Cookie options.Additional context / logs / screenshots / link to code I have a complex setup of 4 authentication schemes: Cookies OpenIdConnect SharePoint (for logging in through sharepoint add-in system) External API key
Both OpenIdConnect and SharePoint use the same cookie authentication to persist login information, and everything worked fine for a while before this change to
GetEffectiveAuthenticationScheme
.What is the rationale behind the change leading to this undocumented behavior and how to properly work around it in my setup?