Php 火基令牌:什么是持有者?
我正在使用此参考存储库测试Lumen内部firebase令牌的身份验证: 在说明中,我很难理解这一部分:Php 火基令牌:什么是持有者?,php,laravel,firebase-authentication,jwt,lumen,Php,Laravel,Firebase Authentication,Jwt,Lumen,我正在使用此参考存储库测试Lumen内部firebase令牌的身份验证: 在说明中,我很难理解这一部分: GET /secret Header: Authorization: "Bearer ...token..." 我正在使用RESTClient(www.RESTClient.net)通过http请求刺激我的Lumen后端。 在那里,我可以定义自定义头,这可能是我在这里需要做的。 所以我这样做了,我已经将name inputfield设置为“authorization”,它已经
GET /secret
Header:
Authorization: "Bearer ...token..."
我正在使用RESTClient(www.RESTClient.net)通过http请求刺激我的Lumen后端。
在那里,我可以定义自定义头,这可能是我在这里需要做的。
所以我这样做了,我已经将name inputfield设置为“authorization”,它已经为我提供了自动完成功能,所以我想这是对的。
然后我移动到属性值字段并键入
持票人…代币
现在,当我发送请求时,我得到以下响应:
UnexpectedValueException in JWT.php line 79: Wrong number of segments
in JWT.php line 79
at JWT::decode('Bearer...token...', 'pawifjopawiejfpoaiwejfpoji', array('HS256')) in AuthServiceProvider.php line 36
at AuthServiceProvider->App\Providers\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in RequestGuard.php line 54
at RequestGuard->user() in GuardHelpers.php line 49
at RequestGuard->check() in GuardHelpers.php line 59
at RequestGuard->guest() in Authenticate.php line 38
at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in RoutesRequests.php line 780
at Application->sendThroughPipeline(array('App\\Http\\Middleware\\Authenticate'), object(Closure)) in RoutesRequests.php line 626
at Application->handleFoundRoute(array(true, array('middleware' => array('auth'), 'uses' => 'App\\Http\\Controllers\\SecretController@index'), array())) in RoutesRequests.php line 528
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 783
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 534
at Application->dispatch(null) in RoutesRequests.php line 475
at Application->run() in index.php line 28
我不知道我是否只是语法错误,或者是否需要提供句点所在的实际数据。
所以不是
持票人…代币
差不多
持票人:代币:
对于那些想自己尝试的人:
在“SecretController.php”中,您需要将代码更改为:
<?php
namespace App\Http\Controllers;
//use Illuminate\Http\Request;
use App\User;
use Firebase\JWT\JWT;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class SecretController extends Controller
{
public function index(Request $request)
{
return new Response('Hello ' . $request->user()->name,
200, ['Content-Type', 'text/plain']);
}
public function pub()
{
return new Response('Hello World', 200, ['Content-Type', 'text/plain']);
}
}
将令牌(真正的访问令牌,而不是“令牌”一词)放入授权头中,例如授权:持有者eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyjzdwiiiiiijmjm0nty3odkwiiiwibmftzsi6ikpvag4grg9liiwiawf0ijoxnte2mjm5mdiyfq.sflkxwrjxmekkqt4f4fpmejf36pok6jjjjjjjjjjjjjjj
Baam,你刚刚救了我一天,谢谢!:)很高兴为您提供帮助:-)将令牌(真正的访问令牌,而不是单词“令牌”)放入授权头中,例如授权:持有者eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyjzdwiiiijm0nty3odkwiiwibmftzsi6ikpvag4grg9liiwiawf0ijoxnte2mjm5mdiyfq.sflkxwrmekkf2qt4fwpmejf36pok6yjv\adQssw5c
Baam,您刚刚救了我一天,谢谢!:)很乐意帮忙:-)