OptionalacrOptionaladapterAllow usage of different types of adapters or a custom adapter to make Keycloak work in different environments.
The following options are supported:
default - Use default APIs that are available in browsers.cordova - Use a WebView in Cordova.cordova-native - Use Cordova native APIs, this is recommended over cordova.It's also possible to pass in a custom adapter for the environment you are running Keycloak in. In order to do so extend the KeycloakAdapter interface and implement the methods that are defined there.
For example:
import Keycloak, { KeycloakAdapter } from 'keycloak-js';
// Implement the 'KeycloakAdapter' interface so that all required methods are guaranteed to be present.
const MyCustomAdapter: KeycloakAdapter = {
login(options) {
// Write your own implementation here.
}
// The other methods go here...
};
const keycloak = new Keycloak();
keycloak.init({
adapter: MyCustomAdapter,
});
OptionalcheckSet to enable/disable monitoring login state.
OptionalcheckSet the interval to check login state (in seconds).
OptionalenableEnables logging messages from Keycloak to the console.
OptionalflowSet the OpenID Connect flow.
OptionalidSet an initial value for the id token (only together with token or
refreshToken).
OptionallocaleWhen onLoad is 'login-required', sets the 'ui_locales' query param in compliance with section 3.1.2.1 of the OIDC 1.0 specification.
OptionallogoutHTTP method for calling the end_session endpoint. Defaults to 'GET'.
OptionalmessageConfigures how long will Keycloak adapter wait for receiving messages from server in ms. This is used, for example, when waiting for response of 3rd party cookies check.
OptionalonSpecifies an action to do on load.
OptionalpkceConfigures the Proof Key for Code Exchange (PKCE) method to use. This will default to 'S256'.
Can be disabled by passing false.
OptionalredirectSpecifies a default uri to redirect to after login or logout. This is currently supported for adapter 'cordova-native' and 'default'
OptionalrefreshSet an initial value for the refresh token.
OptionalresponseSet the OpenID Connect response mode to send to Keycloak upon login.
OptionalscopeSet the default scope parameter to the login endpoint. Use a space-delimited list of scopes.
Note that the scope 'openid' will be always be added to the list of scopes by the adapter.
Note that the default scope specified here is overwritten if the login() options specify scope explicitly.
OptionalsilentSpecifies whether the silent check-sso should fallback to "non-silent" check-sso when 3rd party cookies are blocked by the browser. Defaults to true.
OptionalsilentSpecifies an uri to redirect to after silent check-sso. Silent check-sso will only happen, when this redirect uri is given and the specified uri is available within the application.
OptionaltimeSet an initial value for skew between local time and Keycloak server in
seconds (only together with token or refreshToken).
OptionaltokenSet an initial value for the token.
OptionaluseAdds a cryptographic nonce to verify that the authentication response matches the request.
Configures the 'acr_values' query param in compliance with section 3.1.2.1 of the OIDC 1.0 specification. Used to tell Keycloak what level of authentication the user needs.