I'm new to OAuth. I'm trying to implement https://github.com/lucadegasperi/oauth2-server-laravel#password-flow
I've already inserted id
and secret
into oauth_clients
table. Also I have inserted username and password into users
table. (via Phpmyadmin)
After I try to do the request:
POST http://localhost:8000/oauth/access_token?
grant_type=password&
client_id=weredfsdfsrq341&
client_secret=dfwefsdf&
username=test@test.com&
password=123456
But response is:
{
error: "invalid_request"
error_description: "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter."
}
My route is
Route::post('oauth/access_token', function()
{
return AuthorizationServer::performAccessTokenFlow();
});
What am I doing wrong?
Please make sure the content type is set to "x-www-form-urlencoded" when you make that POST.
Not sure whether you found the answer to this, but, this is a bug in the package as discussed here Here
Basically when the content type is json the parameters are not handled correctly by the package. Fix: Locate $authorizer->setRequest($app['request']);
in vendor/lucadegasperi/oauth-server-laravel/src/OAuth2ServerServiceProvider.php and add this line just above it
$app['request']->replace(\Input::all());
I might be wrong, but I think you missed the parameter scope
. Just a guess.