Php Laravel 5.3 passport ask http身份验证
在我的客户机中,我使用以下路径来获取身份验证令牌Php Laravel 5.3 passport ask http身份验证,php,laravel,oauth-2.0,laravel-5.3,laravel-passport,Php,Laravel,Oauth 2.0,Laravel 5.3,Laravel Passport,在我的客户机中,我使用以下路径来获取身份验证令牌 Route::get('/redirect', function () { $query = http_build_query([ 'client_id' => '1', 'redirect_uri' => 'http://localhost:8001/callback', 'response_type' => 'code', 'scope' =&g
Route::get('/redirect', function () {
$query = http_build_query([
'client_id' => '1',
'redirect_uri' => 'http://localhost:8001/callback',
'response_type' => 'code',
'scope' => ''
]);
return redirect('http://localhost:8000/oauth/authorize?'.$query);
});
Route::get('/callback', function (Illuminate\Http\Request $request) {
$http = new \GuzzleHttp\Client;
$response = $http->post('http://localhost:8000/oauth/token', [
'form_params' => [
'client_id' => '1',
'client_secret' => 'secret-code',
'grant_type' => 'authorization_code',
'redirect_uri' => 'http://localhost:8001/callback',
'code' => $request->code,
],
]);
return json_decode((string) $response->getBody(), true);
});
但当我浏览时,它会询问http身份验证。为什么需要身份验证以及如何解决
今天也有同样的问题,花了很多时间来解决 我终于找到了原因:当您提供一个无效的客户端(错误的clientID或错误的密钥)时,Passport似乎返回了WWW-Authenticate头 事实上,我的凭证中有一个错误,我修复了它们,问题就解决了 希望这有帮助:)