
If you are not going to use Passport's default migrations, you should call the Passport::ignoreMigrations method in the register method of your App\Providers\AppServiceProvider class. Passport::loadKeysFrom(_DIR_.'/./secrets/oauth') Īlternatively, you may publish Passport's configuration file using the vendor:publish Artisan command: php artisan vendor:publish -tag=passport-configĪfter the configuration file has been published, you may load your application's encryption keys by defining them as environment variables: PASSPORT_PRIVATE_KEY="-BEGIN RSA PRIVATE KEY. Typically, this method should be called from the boot method of your application's App\Providers\AuthServiceProvider class: /** You may use the Passport::loadKeysFrom method to accomplish this.

If necessary, you may define the path where Passport's keys should be loaded from. The generated keys are not typically kept in source control: php artisan passport:keys

This command generates the encryption keys Passport needs in order to generate access tokens. When deploying Passport to your application's servers for the first time, you will likely need to run the passport:keys command. After running the passport:install command with the -uuids option, you will be given additional instructions regarding disabling Passport's default migrations: php artisan passport:install -uuids This option will instruct Passport that you would like to use UUIDs instead of auto-incrementing integers as the Passport Client model's primary key values. You may also run the passport:install command with the -uuids option present. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests: 'guards' => [ * Register any authentication / authorization services.įinally, in your application's config/auth.php configuration file, you should set the driver option of the api authentication guard to passport. If your model is already using the Laravel\Sanctum\HasApiTokens trait, you may remove that trait: 'App\Policies\ModelPolicy', This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes. If you would like to use UUIDs as the primary key value of the Passport Client model instead of auto-incrementing integers, please install Passport using the uuids option.Īfter running the passport:install command, add the Laravel\Passport\HasApiTokens trait to your App\Models\User model.


Passport is built on top of the League OAuth2 server that is maintained by Andy Millington and Simon Hamp. Laravel Passport provides a full OAuth2 server implementation for your Laravel application in a matter of minutes.
