Laravel Passport Key 路径 oauth-public.key 不存在或不可读

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39414956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:30:44  来源:igfitidea点击:

Laravel Passport Key path oauth-public.key does not exist or is not readable

laravellaravel-5.3

提问by Sabri Aziri

Laravel passport showing this while trying to access resource

Laravel 护照在尝试访问资源时显示此内容

Key path "file://C:\xampp\htdocs\rental_5.0\storage\oauth-public.key" does not exist or is not readable

回答by Leon Vismer

You do not mention your installation steps. Presume you did the following:

你没有提到你的安装步骤。假设您执行了以下操作:

composer require laravel/passport

Register the service provider inside config/app.php

在里面注册服务提供者 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.

我看到你正在 Windows 上尝试它。我在 Windows 上看到了一个OpenSSL 问题,可能对你有帮助。

回答by Nelson Katale

This is because you didn't generate Oauth keys using passport keys.

这是因为您没有使用护照密钥生成 Oauth 密钥。

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.

输入它询问您的详细信息。然后你就完成了。

回答by Sabri Aziri

OpenSSL was not installed on my windows machine

我的 Windows 机器上没有安装 OpenSSL

  1. Download GnuWi
  2. 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)
  3. Open a new command prompt(Existing ones may not have the newest environment variables)
  4. Run php artisan passport:install
  1. 下载GnuWi
  2. 提取bin/openssl.exe到环境变量路径目录中(您可以在用户文件夹或其他文件夹中创建自己的 bin 文件夹,并将该路径添加到路径变量中)
  3. 打开一个新的命令提示符(现有的可能没有最新的环境变量)
  4. php artisan passport:install

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

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

Edited

已编辑

In windows by using git BASHyou don't need to install any additional software only run php artisan passport:installfrom BASHand it should work.

在使用Windows git BASH,你不要只需要安装运行任何额外的软件php artisan passport:installBASH它应该工作。

回答by laze

I use Heroku. As far as I know, Heroku add OpenSSL support by default (https://devcenter.heroku.com/articles/php-support).

我使用 Heroku。据我所知,Heroku 默认添加 OpenSSL 支持(https://devcenter.heroku.com/articles/php-support)。

All the things, like php artisan install:passportdid run without any issue and my project is also available on the web.

所有的事情,就像php artisan install:passport没有任何问题一样运行,我的项目也可以在网上找到。

When I asked for php artisan route:listthen I received this exception:

当我要求时,php artisan route:list我收到了这个例外:

[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.

我在本地也成功地做了所有事情。在这些步骤之后,git 显示我的存储文件夹中有密钥,所以我提交并将它们推送到 Heroku。

This solved the issue, now everything is okay also on Heroku.

这解决了问题,现在 Heroku 上也一切正常。

(Is it okay, to have the same keys here and there?)

(可以在这里和那里使用相同的密钥吗?)

回答by Udhav Sarvaiya

We get this error because passportis not installed correctly

我们收到此错误是因为passport未正确安装

Solution is simple just run this command:

解决方案很简单,只需运行以下命令:

php artisan passport:install

回答by Mahbub

May be storage/oauth-private.keyand storage/oauth-private.keyis absent and you imported the old database. For this scenario please run the following command.

可能存在storage/oauth-private.key并且storage/oauth-private.key不存在并且您导入了旧数据库。对于这种情况,请运行以下命令。

php artisan passport:keys

Try this solution if you imported the old database where passport related data already stored. Otherwise, follow the accepted answer.

如果您导入了已存储护照相关数据的旧数据库,请尝试此解决方案。否则,请遵循已接受的答案。

回答by ego

Had the same error with Ubuntu and in my case the problem was with permissions, running this solved the issue:

在 Ubuntu 上有同样的错误,在我的情况下问题出在权限上,运行它解决了这个问题:

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

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

回答by Vakar

go straight to .gitignore file in the root of laravel project and remove /storage/*.keyline. Perhaps your server isn't allowing to write the keys file in the directory. Upload or publish your repo again.

直接转到 Laravel 项目根目录中的 .gitignore 文件并删除/storage/*.key行。也许您的服务器不允许在目录中写入密钥文件。再次上传或发布您的回购。

回答by Kamil Kie?czewski

In my case It just doesnt work - I try everyging - probably problem with file access (however ls -lalooks fine) - so i generate that keys in other machine and copy to serwer - and php artisan passport:installstart works

在我的情况下它不起作用 - 我尝试everyging - 文件访问可能有问题(但ls -la看起来不错) - 所以我在其他机器上生成该密钥并复制到服务器 - 然后php artisan passport:install开始工作

回答by Allan Mwesigwa

I manually set my password_clientvalue in the oauth_clientstable to 1and it worked.

我手动将表中的password_client值设置oauth_clients1并且它起作用了。