composer require glocurrency/api-layer
This module use Laravel Passport heavily. In order to make it work properly, follow the steps:
- Run
php artisan glo:apilayer:passport
This command will:
- generate the keys
- copy the migrations from passport
- replace both
client_idanduser_idcolumns in migrations with UUID.
- Copy the passport middlewares to the
$routeMiddlewarein yourapp/Http/Kernel.phpfile:
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,- Add the following code to the
bootmethod ofAuthServiceProvider:
use Glocurrency\ApiLayer\ApiLayer;
public function boot()
{
$this->registerPolicies();
ApiLayer::passport();
}php artisan passport:client --client
php artisan passport:client --personal
After creating your personal access client, place the client's ID and plain-text secret value in your application's .env file:
PASSPORT_PERSONAL_ACCESS_CLIENT_ID=client-id-value
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET=unhashed-client-secret-value- Use
UnauthenticatedTraitin yourapp/Exceptions/Handler.phpfile:
use Glocurrency\ApiLayer\Traits\UnauthenticatedTrait;
class Handler extends ExceptionHandler
{
use UnauthenticatedTrait;Glocurrency Api Layer is open-sourced software licensed under the MIT license.