JWT Auth not working after updates
-
# 2 years, 7 months ago
After wordpress update to 6.0 and the plugin WordPress REST API Authentication to 2.3.0 the JWT token is not working anymore.
Always returning me{ "code": "rest_not_logged_in", "message": "Vous n’êtes actuellement pas connecté.", "data": { "status": 401 } }
Even if I generate a new token.
# 2 years, 7 months agoHi @dearvoodoo-yt,
Could you please share the sample API request you are making?
It would help us to point you in the right direction.
Thanks
Dhruv Bhavsar# 2 years, 7 months agoHey !
So I’m getting the token with this in PHP
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'http://api.mydomain.com/wp-json/api/v1/token', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('username' => $username,'password' => $password), )); $response = json_decode(curl_exec($curl), false); curl_close($curl);
And trying to get users with this (with jQuery)
var token = Cookies.get('jwt_token') var settings = { "url": "https://api.mydomain.com/wp-json/wp/v2/users/me", "method": "GET", "timeout": 0, "headers": { "Authorization": 'Bearer ${token}' }, }; $.ajax(settings).done(function(data) { // do my things here :) });
Not event working with Postman.
But, weirdly working perfectly today just before updating.- This reply was modified 2 years, 7 months ago by dearvoodoo.yt.
- This reply was modified 2 years, 7 months ago by dearvoodoo.yt.
# 2 years, 7 months agoHi @dearvoodoo-yt,
The code looks good to me. Could you please raise the query from the plugin support form?
We can have a screen share meeting to debug the issue for you.Thanks
Dhruv Bhavsar# 2 years, 7 months agoOk I found the problem.
For unknown reason, some options have changed in “Protected REST API Settings”.
The “/wp/v2/users/me” option was no longer checked.
Thanks anyway for your time.
You must be logged in to reply to this topic.