I’m coming from the a previous JWT plugin wp-api-jwt-auth and used it to authenticate to WooCommerce REST routes. However, I needed a way to also authenticate to normal routes (i.e. not part of REST) via JWT, so I thought this plugin might help. And it looks so much more powerful than the old one, I’d love to make it work. I run WordPress v5.3.2.
Somehow I can’t get it to even successfully authenticate to ANY WooCommerce REST route.. It’s all installed (and old plugin deactivated), set up and the /simple-jwt-login/v1 endpoints work: I can generate a JWT and I can do /autologin. But using the JWT as Bearer token in any call to WooCommerce I get 401: woocommerce_rest_cannot_view (e.g. /wp-json/wc/v3/customers/1). The exact same thing does work with the old wp-api-jwt-auth plugin.
When I tried some debugging I found that this plugin doesn’t login the authenticated user.. During the WC permission check ((which happens after the authorization happened) the function get_current_user_id() returns 0, while for the old plugin it returns the user ID of the JWT authenticated user. Is that intended?
Can you recommend anything I could try? If I could find the part of the code it uses to hook into the whole authorization flow I could probably help myself I guess. I’m unable to find that though..
- The topic ‘JWT does not login user’ is closed to new replies.