Laravel Passport invalid

编程入门 行业动态 更新时间:2024-10-24 08:26:58
本文介绍了Laravel Passport invalid_grant用于密码grant_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

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

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

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: 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 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

本文发布于:2023-10-12 16:46:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485297.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   Passport   invalid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!