Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

rest_authentication_errors

$
0
0

Replies: 0

HI,

first of all, thank you for this plugin – It’s really great

I’ve played around with the new (beta) feature to allow rest authentication but it seems that it currently dont implement “rest_authentication_errors” in a correct way

add_filter('rest_authentication_errors', function ($result) {
	if (!empty($result)) {
		return $result;
	}
	if (!is_user_logged_in()) {
		return new WP_Error($_SERVER['REQUEST_URI'] . 'rest_not_logged_in', 'You are not currently logged in.', array('status' => 401));
	}
	return $result;
});	

In theory this code should work, so if I add a correct JWT Token in a API request it should flag me as logged in, but it returns the WP_Error

I’ve used before this plugin: https://github.com/jonathan-dejong/simple-jwt-authentication

and there it is working correctly

Another question: Is it possible to save the decryption_key into the wp-config.php (e.g. define(‘SIMPLE_JWT_LOGIN_SECRET_KEY’,’xxxxxx’)) and not in the database ?

Thank you 🙂

  • This topic was modified 18 minutes ago by lordofdoom.
  • This topic was modified 16 minutes ago by lordofdoom.
  • This topic was modified 15 minutes ago by lordofdoom.

Viewing all articles
Browse latest Browse all 59525

Trending Articles