Skip to content

Instantly share code, notes, and snippets.

@brmeyer
Created January 14, 2015 00:47
import org.jboss.errai.enterprise.client.jaxrs.api.interceptor.RestCallContext;
import org.jboss.errai.enterprise.client.jaxrs.api.interceptor.RestClientInterceptor;
public class KeycloakBearerTokenInterceptor implements RestClientInterceptor {
@Override
public void aroundInvoke(RestCallContext context) {
String bearerToken = getBearerToken();
context.getRequestBuilder().setHeader("Authorization", bearerToken);
context.proceed();
}
public static native String getBearerToken() /*-{
//$wnd.keycloak.updateToken(10);
return "Bearer " + $wnd.keycloak.token;
}-*/;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment