Laravel Passport Key path oauth-public.key does not exist or cannot be read

Laravel passport showing this when trying to access a resource

Key path "file://C:\xampp\htdocs\rental_5.0\storage\oauth-public.key" does not exist or is not readable 
+26
laravel
source share
11 answers

You do not indicate your installation steps. Suppose you did the following:

 composer require laravel/passport 

Register your service provider inside config/app.php

 Laravel\Passport\PassportServiceProvider::class, 

Start migration

 php artisan migrate 

Finally generate the keys using

 php artisan passport:install 

I see that you are trying to use Windows. I noticed that the OpenSSL issue on Windows might help you.

+60
source share

OpenSSL was not installed on my Windows computer

  • Download GnuWi
  • Extract bin/openssl.exe to the path directory of the environment variable (you can create your own bin folder in your user folder or something else and add this path to the path variable)
  • Open a new command line (existing ones may not have the latest environment variables)
  • Run php artisan passport:install

https://github.com/laravel/passport/issues/48#issuecomment-241936338

Edited

In windows using git BASH you don't need to install any additional software, just run php artisan passport:install from BASH and it should work.

+3
source share

I am using Heroku. As far as I know, Heroku is adding OpenSSL support by default ( https://devcenter.heroku.com/articles/php-support ).

All things, such as php artisan install:passport , started without any problems, and my project is also available on the Internet.

When I asked php artisan route:list , I got this exception:

 [LogicException] Key path "file:///app/storage/oauth-private.key" does not exist or is not readable 

Which seems to me the same as above.

I did everything just as well. After these git steps showed that I have a key stored in my storage folder, so I did and clicked them on Heroku.

This solved the problem, now everything is fine on Geroku.

(Everything is in order, are there the same keys here and there?)

+2
source share

We get this error because passport set incorrectly

The solution is simple, just run this command:

 php artisan passport:install 
+2
source share

This is because you did not generate Oauth keys using passport keys.

To run

 php artisan passport:keys 

After that, run the following command to generate the personal access client.

 php artisan passport:client --personal 

Enter the details that ask you. Then you are done.

+2
source share

The same error occurred with Ubuntu, and in my case the problem was with permissions, and this resolved the problem:

sudo chown www-data:www-data storage/oauth-*.key

0
source share

I manually set my password_client value in the oauth_clients 1 table and it worked.

0
source share

Everything worked fine on the local system, ran into the same problem on the production system. In my case, git ignored the keys for a good reason. Just executed php artisan passport:keys on the working server everything worked.

0
source share

Maybe storage/oauth-private.key and storage/oauth-private.key missing and you imported the old database. For this scenario, please run the following command.

 php artisan passport:keys 

Try this solution if you imported an old database in which the data associated with the passport has already been saved. Otherwise, follow the accepted answer.

0
source share

I don't know if this is the ideal solution, but removing /storage/*.key from .gitignore then clicking did .gitignore thing for me.

0
source share

In my case, it just doesnโ€™t work - I try every time - there may be a problem with access to the file (however ls -la looks fine) - so I generate these keys on another computer and copy to serwer - and php artisan passport:install starts working

0
source share

All Articles