How can i obtain an access token executing the call from the federation provider code running in keycloak itself?

Hello,

In one of my protocol mappers in my federation provider jar i call an external service that needs an access token from keycloak to be accessed.

What is the best way to obtain an access token in this scenario?

Currently i am executing an http request to keycloak, but this does not seem to be the best way since the code is running in keycloak itself…

Thank you very much for any help you can provide!