GrantResourceOwnerCredentials()问题

【Help】 【Help】 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

//passWord方式授权
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
var oAuthIdentity = new ClaimsIdentity(context.Options.AuthenticationType);

//Custom code for Match user
if (!UserService.Login(context.UserName, context.Password)) //判断用户名、密码是否正确
{
return;
}

oAuthIdentity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
context.Validated(oAuthIdentity);
}

我这里添加用户名后,在控制器里面是可以通过User.Identity.Name获取对呀的Name,但是这个会有个问题,就是在20分钟后就会变空了,但是那个时候Token还没有过期,按理说应该也不会空的,所以这里是不是少配置什么东西导致了他会20分钟过期?
...全文
评论 7
收藏 已收藏
分享
返回顶部
【Help】
.NET社区 62,271 成员 668,968 内容