【发布时间】:2021-03-28 22:49:36
【问题描述】:
我需要使用传入的访问令牌中的声明在 ASP.NET API 操作中运行一些逻辑。如何获取访问令牌?之后如何获取访问令牌中的声明值?
[HttpGet]
[Authorize(Policy = "PaidMember")]
[Route("GetVideos")]
public async Task<IEnumerable<VideoModel>> GetVideos(string topicId)
{
var accessToken = ... // TODO: Get the access token here
// Then something like the following
var type = accessToken.GetValue("membershiptype") // This line is made up
return await _service.GetVideos(topicId, type );
}
【问题讨论】:
-
这个link可能对你有用
标签: c# asp.net-core asp.net-web-api bearer-token