<tfoot id='E7LZl'></tfoot>

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

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

      1. 如何将 JWT 添加到授权标头?

        How to add JWT to authorization header?(如何将 JWT 添加到授权标头?)
        <legend id='eh7ET'><style id='eh7ET'><dir id='eh7ET'><q id='eh7ET'></q></dir></style></legend>
          <bdo id='eh7ET'></bdo><ul id='eh7ET'></ul>
          • <small id='eh7ET'></small><noframes id='eh7ET'>

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

              <tfoot id='eh7ET'></tfoot>

                <tbody id='eh7ET'></tbody>

                  本文介绍了如何将 JWT 添加到授权标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如下图所述,客户端需要在下一次请求时通过 Authorization Headerjwt 发送回服务器.

                  As described in the following slide, it is necessary that the client sends the jwt back to the server by an Authorization Header at the next request.

                  但是如何定义 Authorization Header 并将 JWT 添加到服务器?

                  But how can I define the Authorization Header and add the JWT to the server?

                  我现在的状态是:

                  1. 用户通过 POST 请求向服务器发送 usernamepassword.
                  2. 服务器创建JWT.
                  3. 服务器将签名后的 JWT 发送回客户端,并将其保存在 cookie 中.
                  1. User sends username and password to the server by a POST request.
                  2. The server creates the the JWT.
                  3. The server sends the signed JWT back to the client and saves it in a cookie.

                  现在我的问题:

                  • 登录时:

                  据我了解,现在有必要将 JWT 发送回服务器.服务器验证令牌并将其发回以完成登录过程.

                  As I understand it, now its necessary to send the JWT back to the server. The server verifies the token and sends it back to finish the login process.

                  如何将 JWT 添加到 Authorization Header?

                  如果运行进程并从计算中接收数据:

                  我是否理解正确,客户端必须将 JWT 从登录发送到服务器,然后将第二个 JWT 与数据一起发送;或者我可以通过 POST 请求发送数据吗?

                  Do I understand right, that the client has to send the JWT from the login to the server and a second JWT with the data; or can I send the data by POST request?

                  推荐答案

                  所以,你对 JWT 来说是非常正确的.从客户端向服务器发送数据时(在创建 JWT 之后),您需要做的就是将其添加到请求标头中.许多人会尝试与 OAuth 保持相同的路径,并添加类似于以下节点片段的 Bearer 令牌:

                  So, You are pretty much correct with JWT. All you need to do when sending data from client to server (after JWT creation), is to add it to the request header. Many folks will try to keep along the same path as OAuth and add a Bearer token similar to the node snippet below:

                  var rp = require('request-promise');
                  options = {
                    method: GET,
                    uri: 'https://www.example.com/api/sample',
                    headers: {
                      Authorization: "Bearer <insert_your_JWT_here>"
                    }
                  }
                  rp(options).then(function(res){
                    <handle_response>
                  }
                  

                  当然,我知道你提到了 PHP,但工作流程是一样的,只是语法不同.

                  Granted I know you mentioned PHP, but the workflows are the same, its just the syntax is different.

                  现在,要验证此令牌是否存在,服务器需要verify() 确认令牌对于已定义的秘密有效.在客户端发出的每个请求中,对于授权端点,您每次都需要发送此令牌.

                  Now, to verify that this token is present, the server would need to verify() that the token is valid with the secret that was defined. In every request made by the client, for an authorized endpoint, you would need to send this token everytime.

                  这篇关于如何将 JWT 添加到授权标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                • <i id='MXnjC'><tr id='MXnjC'><dt id='MXnjC'><q id='MXnjC'><span id='MXnjC'><b id='MXnjC'><form id='MXnjC'><ins id='MXnjC'></ins><ul id='MXnjC'></ul><sub id='MXnjC'></sub></form><legend id='MXnjC'></legend><bdo id='MXnjC'><pre id='MXnjC'><center id='MXnjC'></center></pre></bdo></b><th id='MXnjC'></th></span></q></dt></tr></i><div id='MXnjC'><tfoot id='MXnjC'></tfoot><dl id='MXnjC'><fieldset id='MXnjC'></fieldset></dl></div>
                • <small id='MXnjC'></small><noframes id='MXnjC'>

                    <legend id='MXnjC'><style id='MXnjC'><dir id='MXnjC'><q id='MXnjC'></q></dir></style></legend>
                      <tbody id='MXnjC'></tbody>
                    <tfoot id='MXnjC'></tfoot>

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