阅读(1696) (7)

Laravel 8 请求所有作用域

2021-07-09 12:59:39 更新

使用密码授权机制时,可以通过请求 scope 参数 * 来授权应用程序支持的所有范围的令牌。如果你的请求中包含 scope 为 * 的参数,令牌实例上的 can 方法会始终返回 true。这种作用域的授权只能分配给使用 password 或者 client_credentials 授权时发出的令牌:

$response = $http->post('http://your-app.com/oauth/token', [
    'form_params' => [
        'grant_type' => 'password',
        'client_id' => 'client-id',
        'client_secret' => 'client-secret',
        'username' => '[email protected]',
        'password' => 'my-password',
        'scope' => '*',
    ],
]);