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

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

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

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

        PHP JWT 令牌无效签名

        PHP JWT Token Invalid Signature(PHP JWT 令牌无效签名)
          <i id='sR39o'><tr id='sR39o'><dt id='sR39o'><q id='sR39o'><span id='sR39o'><b id='sR39o'><form id='sR39o'><ins id='sR39o'></ins><ul id='sR39o'></ul><sub id='sR39o'></sub></form><legend id='sR39o'></legend><bdo id='sR39o'><pre id='sR39o'><center id='sR39o'></center></pre></bdo></b><th id='sR39o'></th></span></q></dt></tr></i><div id='sR39o'><tfoot id='sR39o'></tfoot><dl id='sR39o'><fieldset id='sR39o'></fieldset></dl></div>

                <tbody id='sR39o'></tbody>

                <tfoot id='sR39o'></tfoot>
              1. <small id='sR39o'></small><noframes id='sR39o'>

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

                • <bdo id='sR39o'></bdo><ul id='sR39o'></ul>
                  本文介绍了PHP JWT 令牌无效签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我现在正在搜索一个小时,但找不到解决此问题的方法.

                  这是生成 JWT 令牌的代码.我使用了

                  谁能帮我解决这个问题?我目前是 JWT 的新手.顺便说一句,我的项目是 Slim API.

                  非常感谢.

                  解决方案

                  签名验证失败,因为您没有将正确的密钥传递给 https://jwt.io/ 您需要从 PHP 代码中传递 $secretKey 的值.根据屏幕截图,您正在传递字符串 secret.

                  I'm searching for an hours now and can't find a solution to this problem.

                  This is the code to generate JWT token. I used https://github.com/firebase/php-jwt library.

                          $tokenId    = base64_encode(mcrypt_create_iv(32));
                          $issuedAt   = time();
                          $notBefore  = $issuedAt + 10;             //Adding 10 seconds
                          $expire     = $notBefore + 60;            // Adding 60 seconds
                          $serverName = 'serverName'; // Retrieve the server name from config file
                  
                          $secretKey = base64_decode(getenv('JWT_SECRET'));
                  
                           $data = [
                              'iat'  => $issuedAt,         // Issued at: time when the token was generated
                              'jti'  => $tokenId,          // Json Token Id: an unique identifier for the token
                              'iss'  => $serverName,       // Issuer
                              'nbf'  => $notBefore,        // Not before
                              'exp'  => $expire,           // Expire
                              'data' => [                  // Data related to the signer user
                                  'userId'   => '1', // userid from the users table
                                  'userName' => $UserName, // User name
                              ]
                          ];
                  
                          $jwt = JWT::encode(
                                  $data,      //Data to be encoded in the JWT
                                  $secretKey, // The signing key
                                  'HS256'     // Algorithm used to sign the token
                          );
                  
                          $unencodedArray = ['jwt' => $jwt];
                          echo json_encode($unencodedArray);
                  

                  And I verify the token at https://jwt.io/

                  Can anybody help me with this problem? I'm currently new in JWT. Btw, my project is Slim API.

                  Thank you very much.

                  解决方案

                  Signature verification fails because you are not passing the correct secret key to https://jwt.io/ You need to pass the value of $secretKey from the PHP code. According to the screenshot you are passing string secret.

                  这篇关于PHP JWT 令牌无效签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

                        <small id='36GIK'></small><noframes id='36GIK'>

                        <legend id='36GIK'><style id='36GIK'><dir id='36GIK'><q id='36GIK'></q></dir></style></legend>
                          <bdo id='36GIK'></bdo><ul id='36GIK'></ul>
                            <tbody id='36GIK'></tbody>

                          • <tfoot id='36GIK'></tfoot>

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