Esempio n. 1
0
        public static string DecodeJWT(JWTSecurityToken jwt)
        {
            // Create JWT handler
            // This object is used to write/sign/decode/validate JWTs
            JWTSecurityTokenHandler jwtHandler = new JWTSecurityTokenHandler();

            // Serialize the JWT
            // This is how our JWT looks on the wire: <Base64UrlEncoded header>.<Base64UrlEncoded body>.<signature>
            string jwtOnTheWire = jwtHandler.WriteToken(jwt);

            // Parse JWT from the Base64UrlEncoded wire form (<Base64UrlEncoded header>.<Base64UrlEncoded body>.<signature>)
            JWTSecurityToken parsedJwt = jwtHandler.ReadToken(jwtOnTheWire) as JWTSecurityToken;

            return(parsedJwt.ToString());
        }