I have been trying to validate jwt token inside theme function.php file.
I am not sure how to pass this jwt token validate inside this hook function. The following function is working without authorization header also I need to protect the endpoint using jwt authorization without this it should throw a error. lot of example showing javascript based function to fetch the details.
add_action( 'rest_api_init', function ($data) {
register_rest_route( 'jwt-auth/v1', 'sci', array(
'methods' => 'POST',
'callback' => 'update_payment_history',
'permission_callback' => '__return_true'
) );
/* register_rest_route( 'v1', 'certificates', array(
'methods' => 'POST',
'callback' => 'update_payment_history',
'permission_callback' => '__return_true'
) ); */
register_rest_route( 'jwt-auth', 'v1/token', array(
'methods' => 'POST',
'callback' => 'gettoken',
'permission_callback' => '__return_true'
) );
} );
function update_payment_history(WP_REST_Request $request) {
print_r( $request->get_param('transaction_id'));
exit;
}
update_payment_history
? If so, the answer is you do not, that's the function that handles the endpoint if the user has permission, JWT and authentication happens elsewhere. Have you checked the REST API handbooks section on authentication?