简体   繁体   English

阅读SecurityToken C#中的声明

[英]Read claims in SecurityToken C#

I have a access token from OAuth 2.0 which is encrypted using JwtSecurityTokenHandler.WriteToken(). 我有来自OAuth 2.0的访问令牌,它使用JwtSecurityTokenHandler.WriteToken()加密。 After i decrypt it using JwtSecurityTokenHandler.ReadToken(), it returns me SecurityToken Object but i do not know how to loop and read the claim inside the decrypted token. 在我使用JwtSecurityTokenHandler.ReadToken()解密后,它返回我的SecurityToken对象,但我不知道如何在解密的令牌中循环和读取声明。

There is ways to read claim in JwtSecurityToken but unfortunately read token returns SecurityToken instead of JwtSecurityToken. 有方法可以在JwtSecurityToken中读取声明,但不幸的是,读取令牌返回的是SecurityToken而不是JwtSecurityToken。

Hope someone could help. 希望有人能提供帮助。

您应该能够将其转换为JwtSecurityToken

var jwt = jwtSecurityTokenHandler.ReadToken(tokenString) as JwtSecurityToken;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM