I am BeanNguyen.
I am a beginer with Laravel framework. So i want to build a webservice RestAPI (laravel 4.2). I use https://github.com/dingo/api and oauth2 lucadegasperi/oauth2-server-laravel to protect my api. But when i complete all config files and i use Postman ( https://www.getpostman.com/ ) to send request.
I have a error :
*ErrorException (E_UNKNOWN)
Argument 1 passed to Dingo\Api\Auth\LeagueOAuth2Provider::__construct() must be an instance of League\OAuth2\Server\ResourceServer, instance of LucaDegasperi\OAuth2Server\Authorizer given, called in /home/vagrant/Code/webservice/app/config/packages/dingo/api/config.php on line 110 and defined*
So please help me to fix this problem :). This is my config files:
app\routes.php
Route::api('v1', function () {
Route::group(['prefix' => 'protected', 'protected' => true, 'providers' => 'oauth'], function () {
Route::post('user', function () {
$user = API::user();
return $user;
});
});
Route::group(['prefix' => 'unprotected', 'protected' => false], function () {
});
});
app\config\packages\dingo\api\config.php
'auth' => [
'basic' => function ($app) {
return new Dingo\Api\Auth\BasicProvider($app['auth']);
},
'oauth' => function ($app) {
$provider = new Dingo\Api\Auth\LeagueOAuth2Provider($app['oauth2-server.authorizer'], false);
$provider->setUserCallback(function($id) {
return User::find($id);
});
$provider->setClientCallback(function($id) {
return Client::find($id);
});
return $provider;
}
],
app\config\packages\lucadegasperi\oauth2-server-laravel\oauth2.php
'grant_types' => [
'password' => [
'class' => 'League\OAuth2\Server\Grant\PasswordGrant',
'access_token_ttl' => 604800,
// the code to run in order to verify the user's identity
'callback' => function($username, $password){
$credentials = [
'email' => $username,
'password' => $password,
];
if (Auth::once($credentials)) {
return Auth::user()->id;
} else {
return false;
}
}
],
],
and this is my problem:
ErrorException (E_UNKNOWN)
Argument 1 passed to Dingo\Api\Auth\LeagueOAuth2Provider::__construct() must be an instance of League\OAuth2\Server\ResourceServer, instance of LucaDegasperi\OAuth2Server\Authorizer given, called in /home/vagrant/Code/webservice/app/config/packages/dingo/api/config.php on line 110 and defined
Please help me :), thank you very much :)