如何为laravel护照中的特定客户设置特定范围

时间:2018-05-26 20:58:47

标签: laravel oauth-2.0 laravel-passport

Route::get('/', function () {
    $query = http_build_query([
        'client_id' => 3, // Replace with Client ID
        'redirect_uri' => 'http://127.0.0.1:8001/callback',
        'response_type' => 'code',
        'scope' => 'admin user'
    ]);

    return redirect('http://127.0.0.1:8000/oauth/authorize?'.$query);
});

我是使用Laravel Passport的新手,我想动态设置客户端范围,而不是通过硬编码声明范围。

1 个答案:

答案 0 :(得分:0)

不是特定于护照,更多Laravel,但你可以尝试这个

Route::get('/{scope}', function ($scope) {
    $query = http_build_query([
        'client_id' => 3, // Replace with Client ID
        'redirect_uri' => 'http://127.0.0.1:8001/callback',
        'response_type' => 'code',
        'scope' => $scope
    ]);

    return redirect('http://127.0.0.1:8000/oauth/authorize?'.$query);
});

Info here