在使用Laravel Passport 过程中,请求 oauth/token 时遇到如下错误:
{ "error": "unsupported_grant_type", "message": "The authorization grant type is not supported by the authorization server.", "hint": "Check the `grant_type` parameter" }
其实这个错误写的非常详细了,就是 grant_type 错误,解决方法也写上了,就是检查你的 grant_type 配置。
官方文档的示例代码:
$http = new GuzzleHttpClient; $response = $http->post('http://your-app.com/oauth/token', [ 'form_params' => [ 'grant_type' => 'password', 'client_id' => 'client-id', 'client_secret' => 'client-secret', 'username' => 'taylor@laravel.com', 'password' => 'my-password', 'scope' => '', ], ]); return json_decode((string) $response->getBody(), true);
请注意上面的 grant_type,如果没写这个参数或者参数的值不正确,那么就会报unsupported_grant_type,一般我们开发,这个位置的值应该是 password 或者 client_credentials。
声明:1、本博客不从事任何主机及服务器租赁业务,不参与任何交易,也绝非中介。博客内容仅记录博主个人感兴趣的服务器测评结果及一些服务器相关的优惠活动,信息均摘自网络或来自服务商主动提供;所以对本博客提及的内容不作直接、间接、法定、约定的保证,博客内容也不具备任何参考价值及引导作用,访问者需自行甄别。2、访问本博客请务必遵守有关互联网的相关法律、规定与规则;不能利用本博客所提及的内容从事任何违法、违规操作;否则造成的一切后果由访问者自行承担。3、未成年人及不能独立承担法律责任的个人及群体请勿访问本博客。4、一旦您访问本博客,即表示您已经知晓并接受了以上声明通告。
你可能也喜欢
- ♥ Laravel Composer 提示 the requested PHP extension xxx is missing from your system.错误的解决办法07/06
- ♥ 宝塔面板部署 Laravel 提示:The Process class relies on proc_open, which is not available on your PHP installation.07/06
- ♥ Laravel Passport 提示 Class 'AppProvidersPassport' not found 错误的解决办法07/07
- ♥ Laravel 提示 Warning: No such file or directory in D:WWWXXXvendorcomposerautoload_real.php 错误07/06
- ♥ DEDECMS 提示 Error:no csrf hash code!错误的解决办法08/31
- ♥ 倒着写的黑字和白字是什么成语?08/25







