Every realm has its own set of URLs
In Keycloak, a realm is a separate space with its own users, clients, keys and settings. Each realm also has its own endpoints. The token endpoint of realm acme is not the token endpoint of realm master, and a token from one realm is never valid in another.
That is why the realm name appears in almost every URL an app uses. Getting it wrong, or mixing up the server address, is one of the most common reasons an integration fails on the first try.
This page explains how the URLs are built, which ones your app needs, and how to check them.
How Keycloak 26 builds realm URLs
Every realm URL starts with the server’s public address, followed by /realms/ and the realm name. The public address comes from the hostname option. Since Keycloak 17, the default path has no /auth prefix; servers configured with http-relative-path=/auth keep it.
https://<host>[/<relative-path>]/realms/<realm>/<endpoint>Use the realm name exactly as it appears in the admin console, with the same case. A small difference gives an error rather than a redirect.
The endpoints and what they are for
OpenID Connect
| Endpoint | Path under /realms/<realm> | Used for |
|---|---|---|
| Issuer | (the realm URL itself) | The iss claim of every token |
| Discovery | /.well-known/openid-configuration | Lets libraries find everything else |
| Authorization | /protocol/openid-connect/auth | Sends the user to sign in |
| Token | /protocol/openid-connect/token | Exchanges a code, refresh token or client credentials for tokens |
| UserInfo | /protocol/openid-connect/userinfo | Returns the signed-in user’s claims |
| JWKS | /protocol/openid-connect/certs | Public keys to verify token signatures |
| Logout | /protocol/openid-connect/logout | Ends the session (RP-initiated logout) |
| Introspection | /protocol/openid-connect/token/introspect | Asks whether a token is active |
| Revocation | /protocol/openid-connect/revoke | Revokes a refresh or access token |
Less common OAuth flows
The device authorization endpoint (/protocol/openid-connect/auth/device) serves TVs and command-line tools. Pushed authorization requests use /protocol/openid-connect/ext/par/request. Client-initiated backchannel authentication (CIBA) uses /protocol/openid-connect/ext/ciba/auth. Dynamic client registration lives at /clients-registrations/openid-connect.
SAML
SAML clients use /protocol/saml for requests and responses. The realm’s identity provider metadata, with its signing certificate, is at /protocol/saml/descriptor.
Consoles and the admin API
Users manage their own profile, password and sessions in the account console at /realms/<realm>/account. Realm administrators sign in to /admin/<realm>/console/; server administrators use /admin/master/console/. The Admin REST API is under /admin/realms/<realm>, outside the /realms/ path.
What this tool does
Enter the server address and the realm name, and the tool lists every endpoint above as a full URL with a copy button. It also writes three lines you can paste into an app’s environment: the issuer, the discovery URL and the JWKS URL.
If your server still serves under /auth, include it in the address and every URL follows.
What it does not do
It builds URLs from the pattern; it does not call your server. It cannot tell whether the realm exists, whether a feature such as device flow or CIBA is enabled for your clients, or whether the proxy exposes a path. Open the discovery document to see what your server actually supports.
How to use it
- Enter the public address of your Keycloak, the one users see in their browser.
- Add
/authat the end only if your server is configured with that relative path. - Enter the realm name exactly, with the same case.
- Copy the issuer or discovery URL into your app or library settings.
- Open the discovery URL in a browser to confirm the realm answers and the URLs match.
Which URL does your app need?
Most libraries need only one value. Give them the issuer or the discovery URL and they read the rest.
- OpenID Connect libraries for web apps and SPAs usually ask for the issuer or "authority".
- API gateways and resource servers that validate JWTs ask for the issuer and sometimes the JWKS URL.
- Older or hand-written integrations ask for the authorization and token endpoints separately.
- SAML service providers ask for the IdP metadata URL, or the file it returns.
curl -s https://auth.example.com/realms/acme/.well-known/openid-configuration | jq .Testing the token endpoint
Once you have the URLs, a quick request shows whether the realm, the client and the network path all work. For a confidential client with a service account, the client credentials grant is the simplest test, because it needs no browser.
curl -s -X POST https://auth.example.com/realms/acme/protocol/openid-connect/token \
-d grant_type=client_credentials \
-d client_id=billing-service \
--data-urlencode "client_secret=$CLIENT_SECRET"A JSON answer with an access_token means the endpoint, realm and client are right. An invalid_client error points at the client id or secret. A 404 or an HTML page usually means the URL or the proxy path is wrong. The client name and address above are samples.
One server, several realms
Many teams run several realms on one Keycloak: one per product, per customer or per environment. Each realm has its own issuer, keys and sessions, so the URLs differ only in the realm name.
That separation is useful, but it also means an app configured for one realm cannot accept tokens from another, even on the same host. If an API must accept users from two realms, it has to trust two issuers and read two JWKS URLs. Use the master realm only to manage the server, not for your own apps.
Where it helps
Connecting a new app
When a team adds sign-in to a service, the first question is which URLs to configure. The list gives them one source to copy from, built from the same address and realm.
Moving between environments
Staging and production often run the same realm name on different hosts. Generate both sets and keep them in each environment’s configuration, so nothing points at the wrong server after a deploy.
Upgrading from a version with /auth
Servers older than Keycloak 17 served everything under /auth. After an upgrade, apps still configured with /auth/realms/... get 404 errors. Either update every app, or keep http-relative-path=/auth until they are all moved.
Migrating realms to a new server
When realms move to a new host, every app’s issuer changes, and tokens issued by the old server stop being accepted. Plan the switch so users sign in again on the new server, and update issuer settings at the same time.
Common errors and fixes
Realm does not exist
The realm name in the URL does not match a realm on the server. Copy the exact name from the realm list in the admin console.
404 on /auth/realms/...
The server does not use the /auth prefix. Remove it from the URL, or configure http-relative-path=/auth if old clients cannot change yet.
Issuer mismatch
The app expects one issuer and the token carries another, often http instead of https, an internal host name or a different port. Fix the hostname option and proxy headers, then compare the issuer field of the discovery document with the app’s setting.
CORS errors on the token endpoint
Browser apps can only call the token and UserInfo endpoints from origins the client allows. Add the app’s origin to the client’s web origins, or use + to allow the origins of its redirect URIs.
Security notes
- Discovery, JWKS and the issuer URL are public by design. They contain no secrets.
- The admin console and Admin REST API do not need to be on the public address. Many teams serve them only on an internal or admin host.
- Leave dynamic client registration closed to anonymous callers unless you rely on it; it is governed by client registration policies in the realm.
- Never hard-code a JWKS key in an app. Read the JWKS URL, so key rotation does not break validation.
Best practices
- Configure apps with the issuer or discovery URL rather than individual endpoints.
- Keep the server address and realm name in configuration, never in code.
- Use the same public address in every app, in identity provider settings and in documentation.
- After a hostname or proxy change, open the discovery document from outside your network.