Problems setting up SSO with Keycloak

I’m strugglig setting up generic OAuth login with Keycloak.

After clicking on Sign in with OAuth button, I land on Keycloak login screen, and after giving username and password, I get redirected back to grafana, but with a server error message:


In grafana logs I found:

t=2020-04-13T15:44:46+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=302 remote_addr= time_ms=0 size=319 referer=https://grafana.local/login
t=2020-04-13T15:44:59+0000 lvl=info msg="state check" logger=oauth queryState=fb3e8c188015af24e639a2175612132d00560b7c93caaf7e33fb86b21b9ccdec cookieState=fb3e8c188015af24e639a2175612132d00560b7c93caaf7e33fb86b21b9ccdec
t=2020-04-13T15:44:59+0000 lvl=eror msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid_client\",\"error_description\":\"Parameter client_assertion_type is missing\"}"
t=2020-04-13T15:44:59+0000 lvl=eror msg="Request Completed" logger=context userId=0 orgId=0 uname= method=GET path=/login/generic_oauth status=500 remote_addr= time_ms=86 size=1743 referer=""

I haven’t found anything useful on the topic of missing client_assertion_type error. I’m out of ideas how to fix this problem.

My grafana configuration looks like this:

instance_name = grafana.local

root_url = https://grafana.local

admin_user = admin
admin_password = PASSWORD

enabled = true
client_id = grafana
email_attribute_name = email:primary
scopes = openid profile email
auth_url =
token_url =
api_url =
allow_sign_up = false

Not sure it’s relevant for this case, but both keycloak and grafana are behind a proxy that handle TLS termination.

It looks like you have configured Signed JWT or Signed JWT with Client Secret for client authentication in the Keycloak. Use simple Client Id and Secret:

Thanks. That was the problem. It works now.

Hi @jangaraj and @intruz,

While setting up the keycloak with Grafana, I am facing issues, could you please help me on this.

I have configured both grafana as well as keycloak.

While accessing grafana, Grafana URL is redirecting to keycloak and after entering the credentials keycloak is authenticating, however after authenticating it is not redirecting to grafana, it stays up in the keycloak page itself.

setup in keycloak: