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
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
You do not mention your installation steps. Presume you did the following:
composer require laravel/passport
Register the service provider inside config/app.php
Laravel\Passport\PassportServiceProvider::class,
Run the migrations
php artisan migrate
Lastly generate the keys using
php artisan passport:install
I see you are trying it on Windows. I saw an OpenSSL problem on Windows, might help you.
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.
May be storage/oauth-private.key
and storage/oauth-private.key
are 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.
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
We get this error because passport
is not installed correctly
Solution is simple just run this command:
php artisan passport:install
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.
OpenSSL was not installed on my windows machine
bin/openssl.exe
into 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)php artisan passport:install
https://github.com/laravel/passport/issues/48#issuecomment-241936338
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.
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?)
I manually set my password_client
value in the oauth_clients
table to 1
and it worked.
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.
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
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
I don't know if this is the ideal solution but removing /storage/*.key
from .gitignore
then pushing did the trick for me.