Jwt-auth: The token could not be parsed from the request

Created on 8 Jun 2015  路  4Comments  路  Source: tymondesigns/jwt-auth

I read the similar issues but seems like it exists.

Header set: Authorization Bearer .......
Apache .htaccess no problem.

Tymon \ JWTAuth \ Exceptions \ JWTException
HELP
The token could not be parsed from the request
Open: /home/sicakmarka/www/vakademi/vendor/tymon/jwt-auth/src/JWTAuth.php
* @param string $query
* @return JWTAuth
*/
public function parseToken($query = 'token')
{
if (! $token = $this->parseAuthHeader()) {
if (! $token = $this->request->query($query, false)) {
throw new JWTException('The token could not be parsed from the request', 400);
}
}

Most helpful comment

It's highly likely that this is a problem with your apache configuration i.e. it's stripping out the Authorization header.

Have you tried adding:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

to your apache .conf file ?

All 4 comments

It's highly likely that this is a problem with your apache configuration i.e. it's stripping out the Authorization header.

Have you tried adding:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

to your apache .conf file ?

Thank you for your response. I had already tried it and didn't work. I just switched to sending token as parameter ?token={token} and all is fine now.Have a good day.Thanks.

@tymondesigns just a side note.
If apache server is stripping out the Authorization header the .htaccess not always able to override the apache settings. Happened with my and with GoDaddy :) After hours of debugging turned out GoDaddy made a mistake during updating/changing something on their server. I could override a couple of things with the .htaccess file, but the Authorization header rules have been skipped by apache. Had to talk with the support, they confirmed it, it's their fault (after hours they are still trying to fix... terrible)

@csimpi I also have GoDaddy hosting, and I think this just happened very recently. It was working before like last one or two week ago.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phamduong picture phamduong  路  3Comments

gandra picture gandra  路  3Comments

functionpointdaniel picture functionpointdaniel  路  3Comments

aofdev picture aofdev  路  3Comments

Rasoul-Karimi picture Rasoul-Karimi  路  3Comments