Keycloak - Getting 401 in Ajax calls after token e

2019-08-02 10:06发布

I'm using keycloak 3.4.3 Server and 3.4.3 springboot adapter. The login is done with the Java Adapter using the following json configurations:

{
  "realm": "real name",
  "auth-server-url": "http://172.21.34.65/auth",
  "ssl-required": "external",
  "resource": "appName",
  "public-client": true,
  "use-resource-role-mappings": true
}

keycloak client config

The token is refreshed with non ajax calls but when the request contains the header X-Requested-With: XMLHttpRequest the token is not refreshed. Is there a problem with my config or is this the normal behavior and I need to use the JS adapter to refresh the token before the ajax calls?

1条回答
Luminary・发光体
2楼-- · 2019-08-02 10:30

For me an ugly solution was to embed an invisible self-reloading iframe that causes the token refresh. But that is the source of another problem: sometimes the redirect after logging into keycloak leads to the iframe url rather than the desired one. I haven't found a satisfying solution yet.

查看更多
登录 后发表回答