usefulteam / jwt-auth

WordPress JSON Web Token Authentication
https://wordpress.org/plugins/jwt-auth/
124 stars 50 forks source link

Error: Authorization header malformed. #68

Closed e-labInnovations closed 2 years ago

e-labInnovations commented 2 years ago

I followed your documentation and I can generate the token. But the generated token is not working 😥

image

I got a response like this when I tried to use generated token.

{
    "success": false,
    "statusCode": 403,
    "code": "jwt_auth_bad_auth_header",
    "message": "Authorization header malformed.",
    "data": []
}

image image image

pesseba commented 2 years ago

Make sure the .htaccess has the right configuration

e-labInnovations commented 2 years ago

content of my .htaccess file is below

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
e-labInnovations commented 2 years ago

Fixed Problem due to postman Authorization problem. For fixing, selected No Auth in the Authorization Type option