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_id
anduser_id
columns in migrations with UUID.
- Copy the passport middlewares to the
$routeMiddleware
in yourapp/Http/Kernel.php
file:
'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
boot
method 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
UnauthenticatedTrait
in yourapp/Exceptions/Handler.php
file:
use Glocurrency\ApiLayer\Traits\UnauthenticatedTrait;
class Handler extends ExceptionHandler
{
use UnauthenticatedTrait;
Glocurrency Api Layer is open-sourced software licensed under the MIT license.