2016-11-21 50 views
1

尋找Auth0的便捷性來整理我的Angular 2客戶端和Laravel 5.3 API之間的JWT。我已經按照(和雙重檢查,我已經跟隨)Auth0的入門指南:未經授權的用戶從curl調用Auth0調用Laravel 5.3 API

https://auth0.com/docs/quickstart/backend/php-laravel

,但似乎無法得到它我的身份驗證。當我蜷縮如下:

curl --request GET --url http://localhost/api/test --header 'authorization: auth0_id_token' 

我得到:

Unauthorized user curl: (6) Could not resolve host: auth0_id_token 

在我\routes\api,我有:

Route::get('/test', array('middleware' => 'auth0.jwt', function() { 
    return "Hello " . Auth0::jwtuser()->name; 
})); 

我使用這個生成id_token

https://auth0.com/docs/api/authentication#!#post--oauth-ro

和Auth0認爲用戶已經登錄。

的,我應該尋找,試圖調試這任何指針可以看到,當我去(https://manage.auth0.com/#/users)?

回答

1

的正確方法包括在HTTP Authorization頭承載令牌是使用Bearer認證方案,讓您的標題應該是:

Authorization: Bearer [auth0_id_token] 

此外,您從curl收到的錯誤也預示着命令沒有按照你的意圖解析,更具體地說,看起來'authorization: auth0_id_token'被解析爲多個參數,導致auth0_id_token部分被認爲是嘗試解析主機時失敗的URL;嘗試使用雙引號。

+0

非常感謝JoãoAngelo。這正是問題所在,儘管我檢查過我所有的Laravel都是正確的,但我沒有發現我的Curl是錯誤的。如果它幫助其他人,工作命令是:curl --request GET --url localhost/api/test --header「Authorization:Bearer auth0_id_token」。再次感謝。 – theotherdy

相關問題