Laravel Passport

Laravel Passport

Laravel Passport has a passport:install command. However, this command cannot be run in Lambda because it needs to write files to the storage/ directory.

Instead, here is what you need to do:

Generate keys locally

Run the following command on your machine to generate key files:

php artisan passport:keys

This will generate the storage/oauth-private.key and storage/oauth-public.key files, which need to be deployed.

Depending on how you deploy your application (from your machine, or from CI), you may want to whitelist them in serverless.yml:

        - ...
        # Exclude the 'storage' directory
        - '!storage/**'
        # Except the public and private keys required by Laravel Passport
        - 'storage/oauth-private.key'
        - 'storage/oauth-public.key'


You can now redeploy the application:

serverless deploy

Create tokens

Finally, you can create the tokens (which is the second part of the passport:install command):

serverless bref:cli --args="passport:client --personal --name 'Laravel Personal Access Client'"
serverless bref:cli --args="passport:client --password --name 'Laravel Personal Access Client'"

All these steps were replacements of running the passport:install command from the Passport documentation (opens in a new tab).