Add a claim to JWT as an array?

后端 未结 4 1044
醉话见心
醉话见心 2021-01-01 17:52

Using thinktecture JWT authentication resource owner flow,i use the claims part of JWT for client consumption. My question is that if its possible to add claim in identity s

4条回答
  •  情歌与酒
    2021-01-01 18:11

    use JsonClaimValueTypes as claim type

    var tokenDescriptor = new SecurityTokenDescriptor
       {
        Subject = new ClaimsIdentity(new Claim[]
         { new Claim("listName", list != null ? JsonSerializer.Serialize(user.RoleName) : string.Empty,JsonClaimValueTypes.JsonArray)
        }}
    

提交回复
热议问题