*/ class_alias('Tymon\\JWTAuth\\Facades\\JWTFactory', 'JWTFactory'); // Optional // Dingo Response Transformer $app['Dingo\\Api\\Transformer\\Factory']->setAdapter(function ($app) { $fractal = new League\Fractal\Manager(); $fractal->setSerializer(new League\Fractal\Serializer\JsonApiSerializer()); return new Dingo\Api\Transformer\Adapter\Fractal($fractal); }); // Dingo basic auth $app['Dingo\\Api\\Auth\\Auth']->extend('basic', function ($app) { return new Dingo\Api\Auth\Provider\Basic($app['auth'], 'phone'); }); // Dingo OAuth2.0 auth $app['Dingo\\Api\\Auth\\Auth']->extend('oauth', function ($app) { $provider = new Dingo\Api\Auth\Provider\OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { return App\User::findOrFail($id); }); $provider->setClientResolver(function ($id) { // TODO // return OAuthClient::findOrFail($id); }); return $provider; }); // JWT OAuth app('Dingo\\Api\\Auth\\Auth')->extend('jwt', function ($app) { return new Dingo\Api\Auth\Provider\JWT($app['Tymon\\JWTAuth\\JWTAuth']); }); // Dingo Error Format $app['Dingo\\Api\\Exception\\Handler']->setErrorFormat(['error' => ['message' => ':message', 'errors' => ':errors', 'code' => ':code', 'status_code' => ':status_code', 'debug' => ':debug']]);
<?php return ['standardsTree' => env('API_STANDARDS_TREE', 'x'), 'subtype' => env('API_SUBTYPE', ''), 'version' => env('API_VERSION', 'v1'), 'prefix' => env('API_PREFIX', null), 'domain' => env('API_DOMAIN', 'www.laravel.com'), 'name' => env('API_NAME', null), 'conditionalRequest' => env('API_CONDITIONAL_REQUEST', true), 'strict' => env('API_STRICT', false), 'debug' => env('API_DEBUG', false), 'errorFormat' => ['message' => ':message', 'errors' => ':errors', 'code' => ':code', 'status_code' => ':status_code', 'debug' => ':debug'], 'oauth' => function ($app) { $provider = new Dingo\Api\Auth\Provider\OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { return User::findOrFail($id); // Logic to return a user by their ID. }); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. }); return $provider; }, 'throttling' => [], 'transformer' => env('API_TRANSFORMER', 'Dingo\\Api\\Transformer\\Adapter\\Fractal'), 'defaultFormat' => env('API_DEFAULT_FORMAT', 'json'), 'formats' => ['json' => 'Dingo\\Api\\Http\\Response\\Format\\Json']];
|-------------------------------------------------------------------------- | Register Service Providers |-------------------------------------------------------------------------- | | Here we will register all of the application's service providers which | are used to bind services into the container. Service providers are | totally optional, so you are not required to uncomment this line. | */ // $app->register(App\Providers\AppServiceProvider::class); // $app->register(App\Providers\EventServiceProvider::class); $app->register(Dingo\Api\Provider\LumenServiceProvider::class); $app->register(\LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider::class); $app->register(\LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider::class); app('Dingo\\Api\\Auth\\Auth')->extend('oauth', function ($app) { $provider = new Dingo\Api\Auth\Provider\OAuth2($app['oauth2-server.authorizer']->getChecker()); $provider->setUserResolver(function ($id) { // Logic to return a user by their ID. return App\User::find($id); }); $provider->setClientResolver(function ($id) { // Logic to return a client by their ID. }); return $provider; }); /* |-------------------------------------------------------------------------- | Load The Application Routes |-------------------------------------------------------------------------- | | Next we will include the routes file so that they can all be added to