I am using oauth2-server-laravel package, I am new to oauth. I am trying to implement Password Flow method of this library. I am stuck at how to give client_id and client_secret.
Here's my route:
Route::post('oauth', function()
{
return AuthorizationServer::performAccessTokenFlow();
});
This gives response as -
{
"error": "invalid_request",
"error_description": "The user credentials were incorrect."
}
I have inserted client_id and client_secret from mysql. Also seeded users table.
So, Why is this showing error in response? What am I doing wrong?
For newbies who want to use username instead of email (which is the advertised method in their doc), please change to the following in your oauth2.php:
'grant_types' => [
'password' => [
'class' => '\League\OAuth2\Server\Grant\PasswordGrant',
'callback' => function($username, $password) {
if( Auth::validate([
'name' => $username,
'password' => $password,
])){
$user = \App\User::where('name',$username)->first();
return $user->id;
} else {
return false;
}
},
'access_token_ttl' => 3600
]
]