Laravel Passport 基本 api 身份验证返回 "error":"invalid_client","message":"客户端身份验证失败"

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47703425/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:04:07  来源:igfitidea点击:

Laravel Passport basic api auth returns "error":"invalid_client","message":"Client authentication failed"

laravellaravel-5oauth-2.0laravel-passport

提问by Luis L

The Problem

问题

I've been trying to use Laravel Passport and I'm countinously getting the error {"error":"invalid_client","message":"Client authentication failed"}. I have used it in this Android and Laravelproject but I just can register the user correctly as I see the proper data in the database. Then when the Android app tries to get the access token it crashes because the server return the previous error message.

我一直在尝试使用 Laravel Passport 并且多次收到错误 {"error":"invalid_client","message":"Client authentication failed"}。我已经在这个Android 和 Laravel项目中使用了它,但是当我在数据库中看到正确的数据时,我只能正确注册用户。然后,当 Android 应用程序尝试获取访问令牌时,它会崩溃,因为服务器返回了之前的错误消息。

I have also been following this YouTube tutorialexactly as it is explained but I got this error at the part it sends the "access token request".

我也一直完全按照解释的那样关注这个YouTube 教程,但是我在它发送“访问令牌请求”的部分遇到了这个错误。

Postman dataPostman data

邮递员资料邮递员资料

oauth_clients tableDatabase data

oauth_clients 表数据库数据



What I have tried

我试过的

I have tried to fix this using this Stack Overflowpage, this GitHuband many other webpages page but nothing worked

我曾尝试使用此Stack Overflow页面、此GitHub和许多其他网页页面来解决此问题,但没有任何效果

Possible cause

可能的原因

  • I think that it might be the uncompatibility of my laravel version and passport (see below). I have manually changed laravel version to 5.4 but I got a composer error. I don't want to reinstall laravel because i think I could crash all my laravel projects.

  • The 'user_id' column has to be populated by laravel (I have manually changed it to the user_id of the user and after that I restored it to zero) composer.json

  • 我认为这可能是我的 Laravel 版本和护照不兼容(见下文)。我已手动将 Laravel 版本更改为 5.4,但出现作曲家错误。我不想重新安装 Laravel,因为我认为我的所有 Laravel 项目都会崩溃。

  • 'user_id' 列必须由 laravel 填充(我已手动将其更改为用户的 user_id,然后将其恢复为零) 作曲家.json



How to print data to the console? I use error_log() but I can't print variable names and with dd()I get and error saying that the variable couldn't be converted to string.

如何将数据打印到控制台?我使用 error_log() 但我无法打印变量名,并且使用 dd() 我得到错误消息说变量无法转换为字符串。

回答by Agton Cerqueira

Have ever tried configurations like this:? client_id and "client_secret" instead client_password. Your data in param it's the same one that you posted on print "oauth_clients table", right, but I think so your problem is this param "client_password", I never ever seen before this way!

曾经尝试过这样的配置:?client_id 和“client_secret”而不是 client_password。您在参数中的数据与您在打印“oauth_clients 表”上发布的数据相同,对,但我认为您的问题是这个参数“client_password”,我以前从未见过这种方式!

回答by Jignesh Joisar

  1. you have to wrong pass client_id and client_password
  2. if you have to right pass client_id and client_password then check in the database table oauth_clients client_id and client_password is row inserted or not if not added then run this command in console
  1. 您必须错误地传递 client_id 和 client_password
  2. 如果您必须正确传递 client_id 和 client_password 然后检查数据库表 oauth_clients client_id 和 client_password 是否已插入行,如果未添加,则在控制台中运行此命令

php artisan passport:client

php工匠护照:客户

this will register client_id and client_password and then check that in this table(oauth_clients) if not added then maunally added client_id and client_passsword

这将注册 client_id 和 client_password,然后在此表中检查 (oauth_clients) 如果未添加,则手动添加 client_id 和 client_passsword