Calling external API from keycloak during login flow


I am trying to make keycloak call an external API. So far I have made it in he post flow authenticator, and it works on localhost, but as soon as I deploy it to a test server it wont work and I get: “Unexpected error when handling authentication request to identity provider”

The endpoint I am trying to call is my own REST API and works as a proxy for a service that is about to be developed. The endpoint takes 2 parameters which keycloak provides, and then it returns a list. Keycloak is then checking the list and if one parameters matches a parameter from the list, then keycloak will add it to the token

Can it be done from the post login flow authenticator, or do I have to make a mapper?

Or how can this be achieved, if it can be achieved?