在听了很多关于laravel passport的事情后,我考虑将其应用到我的新项目中,我的要求是创建一个将在移动应用程序中使用的API.
So my mobile app is a client
, which will further have its users.
I followed the steps mentioned by Taylor and also read about it here. In a nutshell I followed these steps:
- 已安装
laravel/passport
个. - Created a website user.
- 生成的Passport 密钥
php artisan passport:install
- Generated
client_id
andclient_secret
usingphp artisan passport:client
- Added
redirection
andcallback
routes inweb.php
- 授权用户并获得最终访问令牌.
Then I tried calling api/user
( with Header Authorization
containing value Bearer eyJ0eXAiOiJKV1...(token)
我收到了数据.非常简单和整洁.
但我的应用程序用户不会知道这些细节.所以我想配置Password Grant Tokens个完全符合我的要求.
Now starts the real headache. I've been trying to set this up for the last 3 days and continuously getting
{"error":"invalid_client","message":"Client authentication failed"}
我已经try 了几乎所有我在网上遵循的指南:Redirection Issues、Add Atleast One Scope Solution、P100Y Issue等等.
But I'm still getting invalid client
error. Here's what I'm passing through POSTMAN to oauth/token
:
{
"grant_type": "password,"
"client_id": "3,"
"client_secret": "8BUPCSyYEdsgtZFnD6bFG6eg7MKuuKJHLsdW0k6g,"
"username": "test@gmail.com,"
"password": "123456,"
"scope": ""
}
Any help would be appreciated.