简体   繁体   中英

LogicException: Unable to read key from file file://C:\Users\vivek\pregent-app\app\Providers/../secrets/oauth\oauth-private.key

i am trying to create api token for my apis when my API are run in postman I get this error

LogicException: Unable to read key from file file://C:\Users\vivek\pregent-app\app\Providers/../secrets/oauth\oauth-private.key in file C:\Users\vivek\pregent-app\vendor\league\oauth2-ser

I did some goggling and fount that I need to do

php artisan passport:keys

but when I do I am getting the following error

file_put_contents(C:\Users\vivek\pregent-app\app\Providers/../secrets/oauth\oauth-public.key): Failed to open stream: No such file or directory

inorder to clear this error I tried php artisan config:cache still I am getting same error how can I solve this

note I am using larvel 9

this is the error I am getting

 file_put_contents(C:\Users\vivek\pregent-app\app\Providers/../secrets/oauth\oauth-public.key): Failed to open stream: No such file or directory      

  at C:\Users\vivek\pregent-app\vendor\laravel\passport\src\Console\KeysCommand.php:54
     50▕                 file_put_contents($privateKey, Arr::get($keys, 'privatekey'));
     51▕             } else {
     52▕                 $key = RSA::createKey($this->input ? (int) $this->option('length') : 4096);
     53▕
  ➜  54▕                 file_put_contents($publicKey, (string) $key->getPublicKey());
     55▕                 file_put_contents($privateKey, (string) $key);
     56▕             }
     57▕
     58▕             $this->info('Encryption keys generated successfully.');

  1   C:\Users\vivek\pregent-app\vendor\laravel\passport\src\Console\KeysCommand.php:54
      file_put_contents()

  2   C:\Users\vivek\pregent-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
      Laravel\Passport\Console\KeysCommand::handle()

you can try these commands

php artisan optimize:clear

once your cache is clear then you can do this commands

php artisan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM