Tmeister / wp-api-jwt-auth

A simple plugin to add JSON Web Token (JWT) Authentication to WP REST API
GNU General Public License v2.0
549 stars 159 forks source link

Get Token response and Authorization header not found #211

Open kalhoro opened 3 years ago

kalhoro commented 3 years ago

I've installed plugin in test server and production server. Both servers are returning different response json Test Server response.

{
    "success": true,
    "statusCode": 200,
    "code": "jwt_auth_valid_credential",
    "message": "Credential is valid",
    "data": {
        "token": "eyJ0...",
        "id": 0,
        "email": "myemail@domain.com",
        "nicename": "username",
        "firstName": "My",
        "lastName": "Name",
        "displayName": "My Name"
    }
}

Production server response

{
        "token": "aeK1...",
        "user_email": "myemail@domain.com",
        "user_nicename": "username",
        "user_display_name": "My Name"
    }

I am wondered, without making any changes, just installing plugin and activating in both environments, why json response is different? Also note that keys are different also. i.e. email, user_email etc.

Also in production server, unable to use token for subsequent request. Always returning error jwt_auth_no_auth_header. I tried all the solutions mentioned in articles and answers, to change in htaccess, but none worked for me NOTE: I've cPnael access to the servers only.

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
bigbears67 commented 1 year ago

Hello, I have the same problem have found a solution i'm by ionos and i have the same problem? can you help please ?

davidhealey commented 1 year ago

Late to the party but this might help someone. Are you sure you installed the same JWT Auth plugin on both servers? The older plugin returns the second response you posted while the newer plugin (this one) returns the first response.