Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5.3 passport ask http身份验证_Php_Laravel_Oauth 2.0_Laravel 5.3_Laravel Passport - Fatal编程技术网

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头

事实上,我的凭证中有一个错误,我修复了它们,问题就解决了

希望这有帮助:)