1

I am trying to practice with laravel passport, When i try to install the laravel passport i get this error

file_put_contents(/secret-keys/oauth\oauth-public.key): failed to open stream: No such file or directory

  at C:\xampp\htdocs\test_passport\passme\vendor\laravel\passport\src\Console\KeysCommand.php:46
     42▕             $this->error('Encryption keys already exist. Use the --force option to overwrite them.');
     43▕         } else {
     44▕             $keys = $rsa->createKey($this->input ? (int) $this->option('length') : 4096);
     45▕
  ➜  46▕             file_put_contents($publicKey, Arr::get($keys, 'publickey'));
     47▕             file_put_contents($privateKey, Arr::get($keys, 'privatekey'));
     48▕
     49▕             $this->info('Encryption keys generated successfully.');
     50▕         }

  1   C:\xampp\htdocs\test_passport\passme\vendor\laravel\passport\src\Console\KeysCommand.php:46
      file_put_contents("/secret-keys/oauth\oauth-public.key", "-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAve3QjZA+Q4wtvHUTlAJU
9bThl5i8YpHv+pP4CI6vQxT1lWuanIuM4tnhjxL6xmQlk67IrZOVzhopvI5FsKwY
Uel0pKuHSQEqi7rYcfKydXxXf9QfGadWlcD0rXGc82wtTDYI7Pb7BxjVXoY/cXoM
Zz328OdCcKUifBamef9y1Ffo/fLtYJe4Vdm8hvUB/2sCB9bgzXDZ8PLohYyMHNdq
RWfbWklyAROsxNek2UzZoQdbWzYVTjdWjTIdZL560ZuVRHseFgvsrokXERRoXXNn
BYoFzdvWs8xzWEF3VoVcpAPtCURmp7ka8Y3IsLOAQ81eQbZZ9XkbM6H1xCf6lf+W
yna+6bcE1m6K8qeZlkiIK7fhkkDXSxI4HUijs6sxw4Xf3+eOxaRdbWmHavwOAKsl
KyYvKMPQsjlYXLzXATerVoSzyQpmGD5ikzTE3A/D0hrojxuQr9KffluZ2NbTvceY
p1De9hHhp/8Mrj32xo0gh/rZy/nRgXKhD7wIi7WVQnEOd9qqJtDJbk5VbF9Dh3uJ
N9FG2LLP24y4WBCtbdV7cIprt3Da+B6AiXZqpfZE2YkFpF+uCVftvpEDMmEaDKWI
uS5jA8JdJjp8CColON+0Ou8l0QSccWUleu2f/MLX55HZHMYIHLlbR+4JznaFR1oL
24/fZa75+qy37xywiMUJLaECAwEAAQ==
-----END PUBLIC KEY-----")

  2   C:\xampp\htdocs\test_passport\passme\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
      Laravel\Passport\Console\KeysCommand::handle(Object(phpseclib\Crypt\RSA))

====================================================================================================

I have tried php artisan config:cache composer autoload dump php artisan key:generate

  • Does this answer your question? [file\_put\_contents - failed to open stream: Permission denied](https://stackoverflow.com/questions/4917811/file-put-contents-failed-to-open-stream-permission-denied) – Oleksandr Savchenko Dec 08 '20 at 10:41
  • Did you read the first line? Does this file exist? "/secret-keys/oauth/oauth-public.key" ... if you're on Linux that last slash won't work, you need to fix it. – dagelf Dec 08 '20 at 15:04
  • fixed it and i am not on linux – Mohammad Fahad Rao Dec 09 '20 at 06:43

2 Answers2

1

Try to comment line , in app/Providers/AuthServiceProvider in boot class

Passport::loadKeysFrom(DIR . '/../secrets/oauth')

 public function boot()
{
    $this->registerPolicies();
    // Passport::loadKeysFrom(__DIR__ . '/../secrets/oauth');
}
Ricky Anwar
  • 109
  • 1
  • 5
0

In your file routes/api.php

 use App\Http\Controllers\ControllerName;

Add the name of your controller in ControllerName.

Joundill
  • 6,828
  • 12
  • 36
  • 50
Santosh
  • 11
  • 4
  • Thanks for answering but i fixed it earlier and it was issue in my php versions and configurations as i already replied to my own question above – Mohammad Fahad Rao Feb 03 '21 at 05:44