Reputation: 31
I'm using the AAM plugin (Version 6.5.2) in Wordpress in order to connect users from a node server with JWT tokens.
No problem to use the plugin to authenticate, validate or revocate tokens, but I can't refresh them, because they are... not refreshable... I get a error 405 Error: Request failed with status code 405
with: reason: 'JWT token is not refreshable'
But the possibility seems to exist!
Here is an example of token claim:
{
"iat": 1553820141,
"iss": "https://aamplugin.com",
"exp": 1573225283,
"jti": "b69fc282-2af4-4222-8d81-f405fc6acb8e",
"userId": 1,
"revocable": true,
"refreshable": false
}
I would just like to have a refreshable: true
.
I guess I should use the filter aam_jwt_claims_filter
but I don't know exactly how...
If you have some ideas...
Thanks! Raphaël.
Upvotes: 1
Views: 421
Reputation: 31
For Wordpress advanced users, it will look like basic. But for me, newbie, it wasn't really easy.
I added the following code to the end of the functions.php
of my theme (so in httpdocs/wp-includes
):
add_filter('aam_jwt_claims_filter', function($claims) {
$user = get_user_by('ID', $claims['userId']);
return array_merge($claims, array(
'refreshable' => true,
));
}, 10, 1);
Hope it can help!
Upvotes: 2