nicumicle / simple-jwt-login

This plugin allows you to log in, register, authenticate, delete and change the user password to a WordPress website using a JWT.
http://wordpress.org/plugins/simple-jwt-login/
GNU General Public License v3.0
83 stars 23 forks source link

bug: Not working with woocommerce end point #78

Closed ramdcet closed 1 year ago

ramdcet commented 1 year ago

Hi, I have successfully integrated it with login & register functonality. i want to use it with woocommerce endpoint, when i called the woocommerce end point then it showing error “{ “code”: “woocommerce_rest_cannot_view”, “message”: “Sorry, you cannot list resources.”, “data”: { “status”: 403 } }” . I have enabled the setting from “All WordPress endpoints checks for JWT authentication”. I tried to pass the JWT Token as header/ as authorization but this is not working. Any hepl?

image image ![Uploading image.png…]()

nicumicle commented 1 year ago

Hi @ramdcet,

I just tried it on my side, and all seems to work.

JWT query parameters

Screenshot from 2023-04-15 07-40-42

JWT headers

Screenshot from 2023-04-15 07-42-32

JWT Authorization

Screenshot from 2023-04-15 07-44-14

Have you been able to call other endpoints? For example,

http://{{HOST}}/?rest_route=/wp/v2/posts&JWT={JWT}

One common problem might be that the Authorization header might be missing when you make the request.

Possible Fix 1

So, please make sure that you have the following in your .htaccess file:

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

Possible Fix 2

Another simple way would be to change the header name for "Authorization" to something else in the simple-jwt-login plugin settings (General -> Get JWT token from -> Header). For example, you can try "Auth". image After that, please make a request with the "Auth" header instead of "Authorization".

Let me know if it works after you try these examples.

Best regards, Nicu.

ramdcet commented 1 year ago

Thanks for update

nicumicle commented 1 year ago

@ramdcet, is this issue resolved for you?