How to simulate the login behavior so that the user in keycloak can be added to grafana from backend

Hi, I am integrating my web app with grafana. Now I have configured web app and grafana to same keycloak realm for auto login. I want to invoke a dashboard folder permission api with admin token to let some specific user view the dashboard. The api need the specific “user ID”. But I cannot find the user because the specific user never login grafana before.
Question: Is there a way to sync user in keycloak or simulate the login behavior to add the user to grafana, so that I can find the user id?