Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak.java events are instead exposed as void methods #3

Closed
niloc132 opened this issue Jan 25, 2023 · 0 comments · Fixed by #4
Closed

Keycloak.java events are instead exposed as void methods #3

niloc132 opened this issue Jan 25, 2023 · 0 comments · Fixed by #4
Assignees
Labels
bug Something isn't working

Comments

@niloc132
Copy link

While technically an instance of Keycloak would have a function assigned to its onTokenExpired field, these are intended to be used as event handlers.

See https://www.keycloak.org/docs/latest/securing_apps/#callback-events for documentation on how they are intended to be used.

For example,

public native void onTokenExpired();
could be a field or getter/setter method pair, of some @JsFunction type

@JsFunction
@FunctionalInterface
public interface EventCallback {
  void invoke();
}

Keycloak.java

public EventCallback onTokenExpired;

Then, it can be assigned with a lambda/etc, so that the token can be refreshed:

// from https://stackoverflow.com/a/57855752/860630
keycloak.onTokenExpired = () -> {
  keycloak.updateToken(30);
  //TODO handle errors to return to login screen...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants