Laravel Passport invalid_grant用于密码grant_type [英] Laravel Passport invalid_grant for password grant_type

查看:68
本文介绍了Laravel Passport invalid_grant用于密码grant_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为我的api创建一个 access_token .我已经按照设置进行了操作,并且正在使用邮递员测试/创建令牌.我似乎无法克服 invalid_grant 错误.

我尝试了所有我碰到的运气,但都没有碰到运气.这是我的设置:

发送 POST 请求至: http://mywebsite.local/oauth/token

在主体中,我为此设置了 form-data (名称/值):

  grant_type密码client_id 1client_secret< super_long_string>用户名my@email.com密码机密 

我已经使用过修补程序来创建虚拟用户:

  factory('App \ User')-> create() 

我将新创建的用户用于上面的用户名/密码.

无论我在做什么(不传递任何内容),这都是我经常看到的错误:

  {错误":"invalid_grant","error_description":所提供的授权授予(例如,授权代码,资源所有者凭证)或刷新令牌无效,已过期,已被吊销,与授权请求中使用的重定向URI不匹配,或已颁发给另一个客户端.暗示": "","message":提供的授权授予(例如,授权代码,资源所有者凭证)或刷新令牌无效,已过期,已被吊销,与授权请求中使用的重定向URI不匹配,或者已颁发给另一个客户端.} 

我已经阅读了很多次,这意味着我尝试获取的 grant_type 与客户端不匹配.我正在使用 php artisan Passport:client --password 创建客户端,所以我不明白为什么它无效.我只有一个客户,所以我知道我使用的是正确的 id .此问题似乎是同一件事,我看到了,但是此后已经关闭.>

对于标头,我只设置 Content-Type application/json ,而对Authorization标头没有设置任何内容.

我不确定还有什么尝试.谢谢您的任何建议!

解决方案

此处,从5.8版本开始,默认密码秘密"已更新为密码".所以您输入的是旧密码.

I've been trying to create an access_token for my api. I've followed the setup and am using Postman to test/create a token. I can't seem to get past an invalid_grant error.

I've tried what seems like every combination I've been able to find without any luck. Here is my setup:

Sending a POST request to: http://mywebsite.local/oauth/token

In the body, I am setting form-data to this (name/value):

grant_type      password
client_id       1
client_secret   <super_long_string>
username        my@email.com
password        secret

I've used tinker to create a dummy user:

factory('App\User')->create()

I use the newly created user for my username/password above.

Regardless of what I'm doing (short of not passing anything) this is the error I'm always seeing:

{
    "error": "invalid_grant",
    "error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
    "hint": "",
    "message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}

I've read many times this means the grant_type I'm trying to get doesn't match up to the client. I'm using php artisan passport:client --password to create the client, so I don't understand why it's invalid. I only have one client, so I know I'm using the correct id. This issue seems like the same thing, I am seeing but has since been closed.

For my headers I'm only setting Content-Type application/json, and I have nothing set for Authorization headers.

I'm not sure what else to try. Thank you for any suggestions!

解决方案

as it is stated here, from the 5.8 version the default password "secret" has beeen updated to "password". so you are entering the old password.

这篇关于Laravel Passport invalid_grant用于密码grant_type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆