因爲它往往是這樣,我找到了答案提交問題後,立即...
ApplicationOAuthProvider.cs包含下面的代碼外的開箱
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
using (UserManager<IdentityUser> userManager = _userManagerFactory())
{
IdentityUser user = await userManager.FindAsync(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "The user name or password is incorrect.");
return;
}
ClaimsIdentity oAuthIdentity = await userManager.CreateIdentityAsync(user,
context.Options.AuthenticationType);
ClaimsIdentity cookiesIdentity = await userManager.CreateIdentityAsync(user,
CookieAuthenticationDefaults.AuthenticationType);
AuthenticationProperties properties = CreateProperties(context.UserName, data["udid"]);
AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties);
context.Validated(ticket);
context.Request.Context.Authentication.SignIn(cookiesIdentity);
}
}
通過簡單在方法中添加
var data = await context.Request.ReadFormAsync();
,您可以訪問所有發佈的變量在請求體,並根據需要使用它們。就我而言,我在對用戶進行空檢查後立即將其放置,以執行更嚴格的安全檢查。
希望這可以幫助別人!
var data = await context.Request.ReadFormAsync();'真的幫了我。 – Zapnologica