How to use Confluence as service provider for JWT authentication

Hi,
I have an issue. I have REST endpoint that shows some private data and I want get this data from endpoint using JWT authentication(I don’t need Basic Auth or other). How can I implement plugin that verifies JWT and if token correct send response from endpoint.
I’ve already read How to make REST API endpoints available for JWT authentication article and tried implement, but unfortunately I haven’t understand how it works. If you have some ideas, please advise.