<tfoot id='5OSQj'></tfoot>
      1. <i id='5OSQj'><tr id='5OSQj'><dt id='5OSQj'><q id='5OSQj'><span id='5OSQj'><b id='5OSQj'><form id='5OSQj'><ins id='5OSQj'></ins><ul id='5OSQj'></ul><sub id='5OSQj'></sub></form><legend id='5OSQj'></legend><bdo id='5OSQj'><pre id='5OSQj'><center id='5OSQj'></center></pre></bdo></b><th id='5OSQj'></th></span></q></dt></tr></i><div id='5OSQj'><tfoot id='5OSQj'></tfoot><dl id='5OSQj'><fieldset id='5OSQj'></fieldset></dl></div>
        <legend id='5OSQj'><style id='5OSQj'><dir id='5OSQj'><q id='5OSQj'></q></dir></style></legend>
          <bdo id='5OSQj'></bdo><ul id='5OSQj'></ul>

        <small id='5OSQj'></small><noframes id='5OSQj'>

      2. 使用 Jwt-Dotnet 生成有效令牌

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

              1. <small id='iVCP5'></small><noframes id='iVCP5'>

                <tfoot id='iVCP5'></tfoot>

                  <tbody id='iVCP5'></tbody>
                  本文介绍了使用 Jwt-Dotnet 生成有效令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用以下代码,最初是从

                  通过查看您的代码,您的代码中包含的值是:

                  ConfigurationManager.AppSettings["jwt-key"];

                  只需在秘密"文本框中输入值,如果令牌的签名与 JWT.io 计算的签名匹配,那么您将收到一条消息,说明签名有效.

                  I am using the following code, which I borrowed originally from the jwt-dotnet github page

                      private static string CreateToken(UserPrincipal principal)
                      {
                          /*
                           * https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
                           * http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html
                           */
                          var key = ConfigurationManager.AppSettings["jwt-key"];
                  
                          var claims = new Dictionary<string, string>()
                          {
                              {ClaimTypes.Name, "Rainbow Dash" },
                              {ClaimTypes.WindowsAccountName, "RDash"}
                          };
                  
                          var algorithm = new HMACSHA256Algorithm();
                          var serializer = new JsonNetSerializer();
                          var urlEncoder = new JwtBase64UrlEncoder();
                          var encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
                          var token = encoder.Encode(claims, key);
                          return token;
                      }
                  

                  The above code generates the following token:

                  eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiUmFpbmJvdyBEYXNoIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy93aW5kb3dzYWNjb3VudG5hbWUiOiJSRGFzaCJ9.5WZWDJ0pvTe6QLjVNUeTfZicX_wSsk1dtYvXUbpiOiw

                  So, I hopped over to jwt.io to test my token. I'm told I have an invalid signature.

                  How do I give it a valid 'signature'? I don't understand what my JWT is missing.

                  解决方案

                  The tool over JWT.io can verify the digital signature of your token if you give it the secret signing key you used while creating a token:

                  And from looking at your code it's the value contained in your:

                  ConfigurationManager.AppSettings["jwt-key"];
                  

                  Just input the value inside the "secret" text box and if the signature of the token matches the one calculated by JWT.io then you'll get a message saying that the signature is valid.

                  这篇关于使用 Jwt-Dotnet 生成有效令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Asp Core 2.1 Jwt + 身份.userManager 存储没有实现 IUse 下一篇:如何验证 JWT 令牌

                  相关文章

                  最新文章

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

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

                    1. <tfoot id='JbaH3'></tfoot>

                        <bdo id='JbaH3'></bdo><ul id='JbaH3'></ul>
                    2. <legend id='JbaH3'><style id='JbaH3'><dir id='JbaH3'><q id='JbaH3'></q></dir></style></legend>