Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel API Authentication (Passport); ErrorException in CryptKey.php

ErrorException in CryptKey.php line 57:

Key file "file://C:\wamp\www\project\public_html\storage\oauth-private.key" permissions are not correct, should be 600 or 660 instead of 666

My Configuration as follows:

  • Windows 10 64bit
  • WampServer 3.1.0
  • Apache 2.4.27
  • PHP 7.0.23
  • Laravel Framework version 5.3.31
  • composer require laravel/passport=~1.0

Any idea how to solve it?

like image 472
zarpio Avatar asked Jan 06 '18 14:01

zarpio


People also ask

What is Passport authentication in laravel?

Laravel Passport is an OAuth 2.0 server implementation for API authentication using Laravel. Since tokens are generally used in API authentication, Laravel Passport provides an easy and secure way to implement token authorization on an OAuth 2.0 server.

How can I get token in laravel passport?

Requesting Tokens Once you have created a password grant client, you may request an access token by issuing a POST request to the /oauth/token route with the user's email address and password. Remember, this route is already registered by the Passport::routes method so there is no need to define it manually.

How do I know my passport is installed in laravel?

Check your database. There must be tables about laravel passport. You should post the datas below to '/user' url. You must edit grant_type, client_id and client_secret keys according to values in the oauth_clients table in your database.


2 Answers

You can turn off file checking permissions on line 57

your CryptKey Path is vendor/league/oauth2-server/src/CryptKey.php

on line number 48 turn it to false or comment the following block in your CryptKey.php

   if ($keyPermissionsCheck === true) {
        // Verify the permissions of the key
        $keyPathPerms = decoct(fileperms($keyPath) & 0777);
        if (in_array($keyPathPerms, ['600', '660'], true) === false) {
            trigger_error(sprintf(
                'Key file "%s" permissions are not correct, should be 600 or 660 instead of %s',
                $keyPath,
                $keyPathPerms
            ), E_USER_NOTICE);
        }
    }

keyPermissionsCheck set it to false.

Hope this helps.

like image 191
Romantic Dev Avatar answered Oct 16 '22 19:10

Romantic Dev


Simply CHMOD the oauth-private.key file to 600 or 660. I see that you use Windows so you can surely follow the directions in this post to do that.

like image 2
Justin Avatar answered Oct 16 '22 19:10

Justin