How to authenticate users in a custom SPI?

Hi people! I’m working on a POC expecting to validate users without login screen. I created a extension and put in the flow in Keycloak Admin Page. I’m using the Authorization Code Flow.

I’m able to validate the users using the credentials retrivied from a POST request but instead of give me the authorization code, Keycloak appoints this error:

“HTTP Error 404. The requested resource is not found”.

Is there a way to authenticate users in a custom SPI? Just to authenticate and let Keycloak to give the respective tokens.