Grafana Integration with Keycloak, Error: Login failed Failed to get token from provider

Hi ,
I am trying to integrate Keyclock with Grafana for SSO. below is my configuration in grafana.ini file:

[auth.generic_oauth]
enabled = true
name = Keycloak-OAuth
allow_sign_up = true
tls_skip_verify_insecure = true
client_id = grafana
client_secret = 1234
scopes = openid profile email
groups_attribute_path = groups
auth_url = localhosturl/realms/opx/protocol/openid-connect/auth
token_url = localhosturl/realms/opx/protocol/openid-connect/token
api_url = localhosturl/realms/opx/protocol/openid-connect/userinfo
role_attribute_path = contains(roles[*], 'admin') && 'Admin' || contains(roles[*], 'editor') && 'Editor' || 'Viewer',

below image is my keycloak configuration :

when I try to login to Grafana using ‘Sign in with Keycloak’ option I am getting ‘Login failed
Failed to get token from provider’ error

Can some one pls verify is there any configuration is missing ?. Thanks in advance.

Standard advice: check Grafana server logs first

below are grafana logs:


below are my logs:

Please use formatted text instead of images.

below are my logs, can you please suggest, is the anything I am missing in configuration: 2023-10-

21 15:56:12 logger=authn.service t=2023-10-21T10:26:12.943127657Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
2023-10-21 15:56:12 logger=authn.service t=2023-10-21T10:26:12.943662122Z level=warn msg="Failed to authenticate request" client=auth.client.generic_oauth error="[auth.oauth.token.exchange] failed to exchange code to token: Post \"http://localhost:8080/auth/realms/ox/protocol/openid-connect/token\": dial tcp 127.0.0.1:8080: connect: connection refused"
2023-10-21 15:56:12 logger=context userId=0 orgId=0 uname= t=2023-10-21T10:26:12.947581017Z level=info msg="Request Completed" method=GET path=/login/generic_oauth status=302 remote_addr=172.17.0.1 time_ms=4 duration=4.828545ms size=29 referer= handler=/login/:name
2023-10-21 15:56:12 logger=authn.service t=2023-10-21T10:26:12.950159591Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"

Your Grafana can’t reach keycloak via localhost. Don’t use localhost, but correct domain, ip of keycloak. Also https is required, not plain http.