Keycloak Utils
oidc-spa is provider agnostic. You won’t find any Keycloak-only logic in the core package.
If you are using Keycloak, oidc-spa/keycloak exposes small utilities to leverage Keycloak-specific URLs and endpoints.
Import
import { createKeycloakUtils, isKeycloak } from "oidc-spa/keycloak";Optional runtime check: is this issuer Keycloak?
Useful when your app can run against multiple providers.
const oidc = await getOidc(); // or useOidc() or inject(Oidc)
if (!isKeycloak({ issuerUri: oidc.issuerUri })) {
console.log("The authorization server is not a Keycloak instance");
return;
}Create the utils object
const keycloakUtils = createKeycloakUtils({ issuerUri: oidc.issuerUri });Common use cases
Redirect to the registration page (instead of login)
Link to the Keycloak Account Console
Users can update their profile, password, MFA, sessions, etc.
See: Redirecting to your IdP's account managment page
Fetch the Keycloak user profile (Keycloak-internal endpoint)
This is richer than the decoded ID token.
Equivalent of keycloak-js .loadUserProfile().
Fetch user info (OIDC userinfo endpoint)
userinfo endpoint)Equivalent of keycloak-js .loadUserInfo().
The userInfo object is similarly shaped as what you get if you decode the payload of the access token (which you shouldn't do on the client, see: JWT Of the Access Token)
Admin Console URLs
Only show these links to privileged users (for example realm-admin).
Parse the issuer URI
Last updated
Was this helpful?