<bdo id='01BFu'></bdo><ul id='01BFu'></ul>
<i id='01BFu'><tr id='01BFu'><dt id='01BFu'><q id='01BFu'><span id='01BFu'><b id='01BFu'><form id='01BFu'><ins id='01BFu'></ins><ul id='01BFu'></ul><sub id='01BFu'></sub></form><legend id='01BFu'></legend><bdo id='01BFu'><pre id='01BFu'><center id='01BFu'></center></pre></bdo></b><th id='01BFu'></th></span></q></dt></tr></i><div id='01BFu'><tfoot id='01BFu'></tfoot><dl id='01BFu'><fieldset id='01BFu'></fieldset></dl></div>

      1. <tfoot id='01BFu'></tfoot>

      2. <legend id='01BFu'><style id='01BFu'><dir id='01BFu'><q id='01BFu'></q></dir></style></legend>

        <small id='01BFu'></small><noframes id='01BFu'>

        如何解码 JWT 令牌?

        时间:2023-06-03
              <tbody id='z8iqz'></tbody>
            <i id='z8iqz'><tr id='z8iqz'><dt id='z8iqz'><q id='z8iqz'><span id='z8iqz'><b id='z8iqz'><form id='z8iqz'><ins id='z8iqz'></ins><ul id='z8iqz'></ul><sub id='z8iqz'></sub></form><legend id='z8iqz'></legend><bdo id='z8iqz'><pre id='z8iqz'><center id='z8iqz'></center></pre></bdo></b><th id='z8iqz'></th></span></q></dt></tr></i><div id='z8iqz'><tfoot id='z8iqz'></tfoot><dl id='z8iqz'><fieldset id='z8iqz'></fieldset></dl></div>
            • <bdo id='z8iqz'></bdo><ul id='z8iqz'></ul>
              <legend id='z8iqz'><style id='z8iqz'><dir id='z8iqz'><q id='z8iqz'></q></dir></style></legend>

                <tfoot id='z8iqz'></tfoot>

                <small id='z8iqz'></small><noframes id='z8iqz'>

                • 本文介绍了如何解码 JWT 令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我不明白这个库是如何工作的.你能帮我吗?

                  I don't understand how this library works. Could you help me please ?

                  这是我的简单代码:

                  public void TestJwtSecurityTokenHandler()
                      {
                          var stream =
                              "eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJJU1MiLCJzY29wZSI6Imh0dHBzOi8vbGFyaW0uZG5zY2UuZG91YW5lL2NpZWxzZXJ2aWNlL3dzIiwiYXVkIjoiaHR0cHM6Ly9kb3VhbmUuZmluYW5jZXMuZ291di5mci9vYXV0aDIvdjEiLCJpYXQiOiJcL0RhdGUoMTQ2ODM2MjU5Mzc4NClcLyJ9";
                          var handler = new JwtSecurityTokenHandler();
                  
                          var jsonToken = handler.ReadToken(stream);
                      }
                  

                  这是错误:

                  字符串需要采用紧凑的 JSON 格式,格式为:Base64UrlEncodedHeader.Base64UrlEndcodedPayload.OPTIONAL,Base64UrlEncodedSignature'.

                  The string needs to be in compact JSON format, which is of the form: Base64UrlEncodedHeader.Base64UrlEndcodedPayload.OPTIONAL,Base64UrlEncodedSignature'.

                  如果您将流复制到 jwt.io 网站,它可以正常工作:)

                  If you copy the stream in jwt.io website, it works fine :)

                  推荐答案

                  我找到了解决方案,我只是忘记投射结果了:

                  I found the solution, I just forgot to Cast the result:

                  var stream = "[encoded jwt]";  
                  var handler = new JwtSecurityTokenHandler();
                  var jsonToken = handler.ReadToken(stream);
                  var tokenS = jsonToken as JwtSecurityToken;
                  

                  或者,没有演员表:

                  var token = "[encoded jwt]";  
                  var handler = new JwtSecurityTokenHandler();
                  var jwtSecurityToken = handler.ReadJwtToken(token);
                  

                  我可以通过以下方式获得索赔:

                  I can get Claims using:

                  var jti = tokenS.Claims.First(claim => claim.Type == "jti").Value;
                  

                  这篇关于如何解码 JWT 令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 Selenium 和 C# 通过元素 ID 属性单击单选 下一篇:在 C# 中使用公钥验证使用 RS256 算法签名的 JWT

                  相关文章

                  最新文章

                  <legend id='FnPV6'><style id='FnPV6'><dir id='FnPV6'><q id='FnPV6'></q></dir></style></legend>

                    <bdo id='FnPV6'></bdo><ul id='FnPV6'></ul>

                  <tfoot id='FnPV6'></tfoot>

                    <i id='FnPV6'><tr id='FnPV6'><dt id='FnPV6'><q id='FnPV6'><span id='FnPV6'><b id='FnPV6'><form id='FnPV6'><ins id='FnPV6'></ins><ul id='FnPV6'></ul><sub id='FnPV6'></sub></form><legend id='FnPV6'></legend><bdo id='FnPV6'><pre id='FnPV6'><center id='FnPV6'></center></pre></bdo></b><th id='FnPV6'></th></span></q></dt></tr></i><div id='FnPV6'><tfoot id='FnPV6'></tfoot><dl id='FnPV6'><fieldset id='FnPV6'></fieldset></dl></div>

                    <small id='FnPV6'></small><noframes id='FnPV6'>