Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

glocurrency/api-layer

Repository files navigation

Api Layer

Total Downloads Latest Stable Version License

Installation

composer require glocurrency/api-layer

Passport

This module use Laravel Passport heavily. In order to make it work properly, follow the steps:

  1. Run
php artisan glo:apilayer:passport

This command will:

  • generate the keys
  • copy the migrations from passport
  • replace both client_id and user_id columns in migrations with UUID.
  1. Copy the passport middlewares to the $routeMiddleware in your app/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,
  1. Add the following code to the boot method of AuthServiceProvider:
use Glocurrency\ApiLayer\ApiLayer;

public function boot()
{
    $this->registerPolicies();

    ApiLayer::passport();
}
  1. Generate both Client and Personal grant tokens.
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
  1. Use UnauthenticatedTrait in your app/Exceptions/Handler.php file:
use Glocurrency\ApiLayer\Traits\UnauthenticatedTrait;

class Handler extends ExceptionHandler
{
    use UnauthenticatedTrait;

License

Glocurrency Api Layer is open-sourced software licensed under the MIT license.

FOSSA Status