close

[Solved] Always got “message”: “Unauthenticated.” – Laravel Passport

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Always got “message”: “Unauthenticated.” – Laravel Passport in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Always got “message”: “Unauthenticated.” – Laravel Passport Error Occurs?

Today I get the following error Always got “message”: “Unauthenticated.” – Laravel Passport in php.

How To Solve Always got “message”: “Unauthenticated.” – Laravel Passport Error ?

  1. How To Solve Always got “message”: “Unauthenticated.” – Laravel Passport Error ?

    To Solve Always got “message”: “Unauthenticated.” – Laravel Passport Error The solution is adding this to .htaccess of root folder (not only inside the public folder)

  2. Always got “message”: “Unauthenticated.” – Laravel Passport

    To Solve Always got “message”: “Unauthenticated.” – Laravel Passport Error The solution is adding this to .htaccess of root folder (not only inside the public folder)

Solution 1

In Ubuntu, do the following.

Enable the rewrite mode.

sudo a2enmod rewrite

Go to cd /etc/apache2

Then open apache2.conf nano apache2.conf and find out the following line and change AllowOverride None to AllowOverride All as shown below.

# /etc/apache2/apache2.conf
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Finally, restart apache2 server

sudo service apache2 restart

Solution 2

In order to get detail error message of the causes, you need to go to CheckClientCredentials class detail as below

public function handle($request, Closure $next, ...$scopes)
{
    $psr = (new DiactorosFactory)->createRequest($request);

    try {
        $psr = $this->server->validateAuthenticatedRequest($psr);
    } catch (OAuthServerException $e) {
        error_log($e->getHint()); // add this line to know the actual error
        throw new AuthenticationException;
    }

    $this->validateScopes($psr, $scopes);

    return $next($request);
}

Based on the error message. in my question.

The solution is adding this to .htaccess of root folder (not only inside the public folder)

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

There’s also a note in the official documents refer here

Without above configuration, the Authorization header will be ignored during call from anywhere to app. Once ignored, inside class will unable to retrieve this header data

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment