![](/img/trans.png)
[英]Laravel Passport - Invalid credentials using grant_type is passowrd
[英]How to enable client credentials grant type in laravel passport
我正在尝试使用laravel 5.3开发使用令牌的静态API进行身份验证。 我还添加了laravel护照,我认为这将帮助我更快地构建api。 我想通过api提供的资源是所有用户共有的,而用户没有特定的资源。 所以我认为应该使用授权类型:客户端凭据。 我在laravel文档中找不到有关此授予类型的任何帮助
https://github.com/laravel/passport/pull/34/files此链接显示客户端凭据授予类型已添加到laravel护照。 但是当我尝试授予类型作为客户端凭据时
$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'),
],
]);
它给出了使用的授予类型错误。
我使用的是客户端凭据方法,因为它是一台机器到机器的调用。 我收到类似{“ error”:“未经身份验证”的错误。 }`使用邮递员时。 我使用了访问类型和授权标头,但遇到了相同的错误。 然后我用谷歌搜索并尝试了下面链接中解释的方法。 有效。 :) :) http://filljoyner.com/2017/03/01/how-to-use-client-credentials-grant-tokens-for-your-api-authorization-with-laravel-5-4s-passport/
当您安装Laravel Passport时,默认情况下在oath_clients表中安装了一个密码授予,但password_client列应为1而不是0。
然后,您将一些 form_data发送到/oauth/token
url并获得access_token
作为回报。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.