jwt_auth_no_auth_header error on validating WordPress REST API JWT token
I was facing the same problem, until i change the order of lines on my htaccess.Initially,i put the lines
RewriteCond %{HTTP:Authorization} ^(.*)RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
at the end of the rules.
After those lines where only after the RewriteEngine On, the error jwt_auth_no_auth_header was fixed.On jwt authentication for wp rest api
<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{HTTP:Authorization} ^(.*)RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]RewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>
In case someone else faces this issue, this code that I added to .htaccess
is probably not working
# Enable HTTP AuthRewriteCond %{HTTP:Authorization} ^(.*)RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
So in the plugin file jwt-authentication-for-wp-rest-api/class-jwt-auth-public.php
, look in the function named validate_token
, after the $auth
check fails I added this piece of code :
if (!$auth) { $allHeaders = getallheaders(); $auth = isset($allHeaders['Authorization']) ? $allHeaders['Authorization'] : false;}
This will get that Authorization
header and JWT will work as expected