I'm working on a Laravel 4.2 app built with dingo/api and NeoEloquent to support Graph databases. I want to implement OAuth, probably using lucadegasperi/oauth2-server-laravel, but this doesn't work with NeoEloquent. After I created a Client in the database, when trying Authorizer::issueAccessToken() I get the following error:
exception 'League\OAuth2\Server\Exception\InvalidClientException' with message 'Client authentication failed.' in /home/vagrant/code/vendor/league/oauth2-server/src/Grant/PasswordGrant.php:114
Stack trace:
#0 /home/vagrant/code/vendor/league/oauth2-server/src/AuthorizationServer.php(275): League\OAuth2\Server\Grant\PasswordGrant->completeFlow()
#1 /home/vagrant/code/vendor/lucadegasperi/oauth2-server-laravel/src/Authorizer.php(80): League\OAuth2\Server\AuthorizationServer->issueAccessToken()
#2 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(205): LucaDegasperi\OAuth2Server\Authorizer->issueAccessToken()
I can't find any OAuth implementation for Laravel that supports Graph databases or works with NeoEloquent. Does anyone have any idea on how to work this out?
Update
A part of my composer.json:
"require": {
"laravel/framework": "4.2.*",
"vinelab/neoeloquent": "*",
"laravelbook/ardent": "~2.4",
"doctrine/dbal": "~2.5",
"lucadegasperi/oauth2-server-laravel": "3.*",
"dingo/api": "0.8.*"
},
All my models extend my own NeoArdent, which is a copy of laravelbook/Ardent with some changes in relationship definitions to make it work with NeoEloquent.
My grant types in app/config/packages/lucadegasperi/oauth2-server-laravel/oauth2.php
'grant_types' => [
'password' => [
'class' => '\League\OAuth2\Server\Grant\PasswordGrant',
'callback' => function($username, $password) {
if( Auth::validate([
'email' => $username,
'password' => $password,
])){
$user = User::where('email', $username)->first();
return $user->id;
} else {
return false;
}
},
'access_token_ttl' => 3600
]
]
My authentication provider definition in app/config/packages/dingo/api/config.php
'auth' => [
'oauth' => function ($app) {
$provider = new Dingo\Api\Auth\LeagueOAuth2Provider($app['oauth2-server.authorizer']->getChecker());
$provider->setUserResolver(function ($id) {
return User::findOrFail($id);
});
$provider->setClientResolver(function ($id) {
return User::findOrFail($id);
});
return $provider;
}
]
Before I try to get the auth code I temporarily use this to create a client:
if (!DB::table('oauth_clients')->count()) {
$client = [
'id' => 'angularApp',
'secret' => 'angularAppSecret',
'name' => 'angularApp'
];
DB::table('oauth_clients')->insert($client);
}
And after that I do this:
Auth::login($user);
Input::merge(['grant_type' => 'password', 'client_id' => 'angularApp', 'client_secret' => 'angularAppSecret']);
return AuthorizerFacade::issueAccessToken();
which gives me the error above.
I hope this helps a bit in understanding my problem.