5
如何從ASP.NET Core 2.0中的HttpContext獲取AuthenticationInfo
屬性。我明白,隨着ASP.NET Core 2.0中安全性的重新設計,AuthenticationManager
現在已經過時,我應該刪除.Authentication
。在ASP.NET Core 2.0中獲取AuthenticationInfo
我以前做這樣的事情在1.1.2
var info = await httpContext.Authentication.GetAuthenticateInfoAsync("Automatic");
info.Properties.StoreTokens(new List<AuthenticationToken>
{
new AuthenticationToken
{
Name = OpenIdConnectParameterNames.AccessToken,
Value = accessToken
},
new AuthenticationToken
{
Name = OpenIdConnectParameterNames.RefreshToken,
Value = refreshToken
}
});
await httpContext.Authentication.SignInAsync("Automatic", info.Principal, info.Properties);
注「自動」不再是一個關鍵詞。只需調用'.AuthenticateAsync();' – Tratcher
@Tratcher很好的接收,謝謝。我確定我已經編輯了我的答案,用[scheme]取代了Automatic,但看起來我忘了保存我的編輯。也就是說,你是對的,它可能更容易使用默認方案進行身份驗證和登錄,所以我相應地更新了我的答案。 – Pinpoint