<legend id='NmVUi'><style id='NmVUi'><dir id='NmVUi'><q id='NmVUi'></q></dir></style></legend>
    <bdo id='NmVUi'></bdo><ul id='NmVUi'></ul>

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

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

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

        如何从 Laravel 的请求中获取 Bearer 令牌

        时间:2023-12-01

          • <tfoot id='3pnt3'></tfoot>
            <i id='3pnt3'><tr id='3pnt3'><dt id='3pnt3'><q id='3pnt3'><span id='3pnt3'><b id='3pnt3'><form id='3pnt3'><ins id='3pnt3'></ins><ul id='3pnt3'></ul><sub id='3pnt3'></sub></form><legend id='3pnt3'></legend><bdo id='3pnt3'><pre id='3pnt3'><center id='3pnt3'></center></pre></bdo></b><th id='3pnt3'></th></span></q></dt></tr></i><div id='3pnt3'><tfoot id='3pnt3'></tfoot><dl id='3pnt3'><fieldset id='3pnt3'></fieldset></dl></div>
                <tbody id='3pnt3'></tbody>
            1. <small id='3pnt3'></small><noframes id='3pnt3'>

                <bdo id='3pnt3'></bdo><ul id='3pnt3'></ul>
              • <legend id='3pnt3'><style id='3pnt3'><dir id='3pnt3'><q id='3pnt3'></q></dir></style></legend>
                  本文介绍了如何从 Laravel 的请求中获取 Bearer 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我期望来自所有传入请求的 JWT 令牌,它应该包含在请求标头中,例如:Authorization =>;'Bearer:这里有一些令牌'

                  I am expecting a JWT token from all the incoming request, and it should be included on request headers like: Authorization => 'Bearer: some token here'

                  我想得到这个令牌并验证它:这是我正在尝试的:

                  I want to get this token and verify it: here is what I am trying:

                  $token = $request->header('Authorization');
                  

                  这就是我得到的:

                  <代码> 授权:承载:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJleGFtcGxlLm9yZyIsImF1ZCI6ImV4YW1wbGUuY29tIiwiaWF0IjoxMzU2OTk5NTI0LCJuYmYiOjEzNTcwMDAwMDB9.UQUJV7KmNWPiwiVFAqr4Kx6O6yd69lfbtyWF8qa8iMN2dpZZ1t6xaF8HUmY46y9pZN76f5UMGA0p_CMqymRdYfNiKsiTd2V_3Qpt9LObaLg6rq18j3GLHfdr8nyBzO3v7gTpmNaU6Xy47aMDsbcs593Lx_lD3PnO41oEHgih7CsRKW1WcW1radnpEhdDO7-GpmGOF6xUnpAlQ9EHqpqnIlZPbVoJg92Iwozn-07uuWrkyKUpYN4IPpstd1ks3cKlJ6FH-2ROiC4N0MVLxp4lhUyKhLdwgDWYH4tjtdrEVK0a3_zVtK1ukvriEJqMkfYHnE6Bwv_pv_-lRNy_y7m-YQ"

                  问题有没有办法只获取不包括Authorization: Bearer"的令牌当然我可以解析整个字符串并获取令牌,但我只是想知道是否有另一种方法可以在不解析的情况下获取它.

                  Question is there any way to grab only the token not including "Authorization: Bearer" and of course I could parse the whole string and get the token, but I am just wondering if there is another way of getting it without parsing.

                  推荐答案

                  IlluminateHttpRequest对象上有一个bearerToken()方法,所以你应该能够只做 $token = $request->bearerToken(); 并得到你所期望的(在 Laravel 5.5 中 - 我不确定以前的版本).

                  There is a bearerToken() method on the IlluminateHttpRequest object, so you should be able to just do $token = $request->bearerToken(); and get back what you expect (that's in Laravel 5.5 - I'm not sure of previous versions).

                  这篇关于如何从 Laravel 的请求中获取 Bearer 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我不明白 JWT 刷新令牌的行为 (LARAVEL) 下一篇:多用户模型 Laravel JWT Auth

                  相关文章

                    <legend id='ESPcJ'><style id='ESPcJ'><dir id='ESPcJ'><q id='ESPcJ'></q></dir></style></legend>
                  1. <tfoot id='ESPcJ'></tfoot>

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