André Figueira

Systems engineer - I write apps, I make websites, opinions are my own...

Fix Laravel Passport key not readable issue

I recently updated my Lumen project to get the latest Laravel Passport 3.0 update, the moment I tried to make a request however after the update I got the following error

    "error": {
        "code": 500,
        "message": "Key path \"file:///app/storage/oauth-public.key\" does not exist or is not readable"

At first I thought it was some breaking change that had come along, however after a little bit of research, it's an additional check that's being done by the underlying PHP league oauth package which is causing stricter permission and ownership checks, which we should have really been obeying before, e.g. Key should be owned by the same user that will access it, so that means if your permissions to the key files are incorrect or the ownership is wrong, you'll get this error. e.g. files owned by root, but your PHP runs under the apache user, etc...

So to fix it, simply ensure that the files are owned by the same user which is accessing them and just run a chown against the keys to correct it and while you're at it make sure you have the correct permissions!

# Replace correctuser:correctgroup with the obvious...
sudo chown correctuser:correctgroup storage/oauth-*.key

# Set the correct permissions if they aren't already
sudo chmod 0600 storage/oauth-*.key 

Hope this helps anyone that's panicking that their authentication isn't working.

Related Laravel\Passport issues: