如何在Laravel中使用护照取回访问令牌?

我只是按照Laravel official中的步骤进行操作。
我正在使用邮递员发送发帖请求(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."}

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

canyu1 回答:如何在Laravel中使用护照取回访问令牌?

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

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

普通客户端未启用密码授予。

,

请检查您的oauth_clients表-确保:

  1. 您的client_id是正确的

  2. 您的client_secret是正确的

  3. 您的客户端password_client值设置为1

问题可能出在最后一部分。

,

如果您使用客户端凭据访问OAuth令牌,则使用的Grant_type为 client_credentials

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

以下是一些文档:-https://laravel.com/docs/5.4/passport#client-credentials-grant-tokens

,

邮递员

Accept : application/json
Authorization : Bearer token  //here pass token and token is equal to your login time token(write like Bearer space token) 
本文链接:https://www.f2er.com/3008049.html

大家都在问