首页 > 解决方案 > 如何在laravel中使用护照检索访问令牌?

问题描述

我只是按照Laravel 官方中的步骤进行操作。
我正在使用邮递员发送发布请求(http://localhost:7777/my-project/public/oauth/token),因此我可以检索访问令牌:

{
  "grant_type" : "password",
  "client_id" : "2",
  "client_secret" : "oxKBv6EnyEXeF6l4FBbkVcLgq2WPnyB9EOdlUpL5",
  "username" : "my_email",
  "password" : "my_password",
  "scope" :""
}

我收到此错误:

{"error":"invalid_credentials","message":"The user credentials were incorrect."}

即使我确定我的凭据是正确的。

标签: laravellaravel-passport

解决方案


您的客户端必须设置为密码授权客户端才能使用密码授权:

https://laravel.com/docs/5.5/passport#creating-a-password-grant-client

普通客户端没有启用密码授权。


推荐阅读