'Laravel Passport Key path oauth-public.key does not exist or is not readable
Laravel passport showing this while trying to access resource
Key path "file://C:\xampp\htdocs\rental_5.0\storage\oauth-public.key" does not exist or is not readable
Solution 1:[1]
This is because you didn't generate Oauth keys using passport keys.
Run
php artisan passport:keys
After that run the following command to generate a personal access client
php artisan passport:client --personal
Enter the details it asks you. Then you are done.
Solution 2:[2]
May be storage/oauth-private.key and storage/oauth-private.key is absent and you imported the old database. For this scenario please run the following command.
php artisan passport:keys
Try this solution if you imported the old database where passport related data already stored. Otherwise, follow the accepted answer.
Solution 3:[3]
Had the same error with Ubuntu and in my case the problem was with permissions, running this solved the issue:
sudo chown www-data:www-data storage/oauth-*.key
Solution 4:[4]
We get this error because passport is not installed correctly
Solution is simple just run this command:
php artisan passport:install
Solution 5:[5]
OpenSSL was not installed on my windows machine
- Download GnuWi
- Extract
bin/openssl.exeinto a Environment Variable Path directory (You can create your own bin folder in your user folder or something and add that path to the Path Variable) - Open a new command prompt(Existing ones may not have the newest environment variables)
- Run
php artisan passport:install
https://github.com/laravel/passport/issues/48#issuecomment-241936338
Edited
In windows by using git BASH you don't need to install any additional software only run php artisan passport:install from BASH and it should work.
Solution 6:[6]
go straight to .gitignore file in the root of laravel project and remove /storage/*.key line. Perhaps your server isn't allowing to write the keys file in the directory. Upload or publish your repo again.
Solution 7:[7]
I use Heroku. As far as I know, Heroku add OpenSSL support by default (https://devcenter.heroku.com/articles/php-support).
All the things, like php artisan install:passport did run without any issue and my project is also available on the web.
When I asked for php artisan route:list then I received this exception:
[LogicException]
Key path "file:///app/storage/oauth-private.key" does not exist or is not readable
What seems to me the same as above.
I did everything also local successfully. After these steps git showed I have the key filed in my storage folder, so I committed and pushed them to Heroku.
This solved the issue, now everything is okay also on Heroku.
(Is it okay, to have the same keys here and there?)
Solution 8:[8]
I manually set my password_client value in the oauth_clients table to 1 and it worked.
Solution 9:[9]
Everything worked fine on the local system, faced the same problem on production system. In my case, git ignored keys for good reason.
Just executed php artisan passport:keys on production server everything worked.
Solution 10:[10]
I don't know if this is the ideal solution but removing /storage/*.key from .gitignore then pushing did the trick for me.
Solution 11:[11]
In my case It just doesnt work - I try everyging - probably problem with file access (however ls -la looks fine) - so i generate that keys in other machine and copy to serwer - and php artisan passport:install start works
Solution 12:[12]
Adding this to composer.json did the trick for me:
"scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize", "chmod -R 777 storage", "php artisan passport:keys" ], }
https://github.com/laravel/passport/issues/267#issuecomment-346627625
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
