我正在尝试开发一个使用token的restful api,用于使用laravel 5.3进行身份验证。我还添加了laravel passport,我认为它可以帮助我更快地构建api。我想通过api提供的资源对所有用户都是通用的,没有特定于用户。所以我想我应该使用授权类型:客户端凭证。我在laravel文档中找不到任何关于这种奖励类型的帮助
https://github.com/laravel/passport/pull/34/files此链接显示添加到laravel passport的客户凭证授予类型。但是当我尝试将授权类型指定为客户端凭据时
$http = new \GuzzleHttp\Client;
$response = $http->post('http://site.dev/oauth/token', [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => config('api.client_id'),
'client_secret' => config('api.client_secret'),
'redirect_uri' => config('api.redirect_uri'),
],
]);
它在使用的授权类型中给出错误。
发布于 2017-06-28 16:47:30
我使用客户端凭据方法,因为它是机器对机器的调用。我在使用postman时收到类似{ " error ":"Unauthenticated.“}`的错误。我使用了访问类型和授权标头,但得到了相同的错误。然后我在谷歌上搜索并尝试了下面链接中解释的方法。啊,真灵。:) :) http://filljoyner.com/2017/03/01/how-to-use-client-credentials-grant-tokens-for-your-api-authorization-with-laravel-5-4s-passport/
发布于 2016-10-07 15:13:11
当您安装Laravel Passport时,默认情况下会在oath_clients表中安装一个密码授予,但password_client列应该是1而不是0。
然后将some form_data发送到/oauth/token
url并返回access_token
。
https://stackoverflow.com/questions/39849274
复制相似问题