Skip to content

OIDC authorization URL builder for Keycloak

Build an OpenID Connect authorization URL with client id, redirect URI, scope, state, nonce and PKCE, using Keycloak’s endpoint or any other.

Runs in your browser. Nothing you paste is sent to us.

Request

The base URL, without /realms/…. Add a path if your server has one, such as /auth on old versions.

Must match one of the client’s Valid redirect URIs.

Separated by spaces. openid makes it an OpenID Connect request.

A username or email to fill in on the sign-in page.

The alias of an identity provider: Keycloak skips its own sign-in page and goes there.

One name=value per line.

Authorization URL

URL
https://auth.example.com/realms/acme/protocol/openid-connect/auth?response_type=code&client_id=web-app&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=openid%20profile%20email&code_challenge_method=S256

Open in a new tab

response_type
code
client_id
web-app
redirect_uri
https://app.example.com/callback
scope
openid profile email
code_challenge_method
S256
Keep for the token request: code_verifier
 
Keep state, nonce and the code verifier in the user’s session. When the user comes back, check state, then send the code and the verifier to the token endpoint.

How to use it

  1. Enter your Keycloak server URL and realm, or switch to a custom authorization endpoint.
  2. Fill in client_id and redirect_uri exactly as they are registered.
  3. Choose the scopes; state, nonce and a PKCE pair are made for you.
  4. Copy the URL or open it, and keep the code_verifier for the token request.

What to know

The authorization request is a browser redirect to the authorization endpoint. In Keycloak that is https://<host>/realms/<realm>/protocol/openid-connect/auth.

Use response_type=code with PKCE. The implicit flow (response_type=token) returns tokens in the URL, where they leak through history and logs, and RFC 9700 says not to use it.

kc_idp_hint is a Keycloak parameter: give it an identity provider’s alias and Keycloak sends the user straight to that provider.

What an authorization request is

Every OAuth 2.0 and OpenID Connect sign-in starts the same way. The app sends the user’s browser to the authorization server with a set of query parameters. The server signs the user in, asks for consent if needed, and redirects back to the app with a result.

That first redirect is the authorization request. RFC 6749 section 4.1.1 defines its core parameters, and OpenID Connect Core 1.0 section 3.1.2.1 adds the ones for signing in, such as nonce and prompt. A wrong value here is behind many sign-in bugs, which is why it pays to build the URL carefully and read it back.

The parameters, one by one

ParameterRequiredWhat it does
response_typeYescode for the authorization code flow
client_idYesThe client’s id at the server
redirect_uriYes in OpenID ConnectWhere the browser comes back; must match a registered value
scopeYes in OpenID ConnectSpace-separated; openid turns on OpenID Connect
stateRecommendedRandom value checked on the callback
nonceRecommended for code flowRandom value copied into the ID token
code_challengeRecommendedPKCE hash of the code verifier
code_challenge_methodWith PKCES256
response_modeNoquery, fragment or form_post
promptNonone, login, consent or select_account
login_hintNoPrefills the username on the sign-in page

Servers may define their own parameters too. Keycloak reads kc_idp_hint, for example, which is covered below.

An example request and response

Sample authorization URL for the realm acme (values are made up)
https://auth.example.com/realms/acme/protocol/openid-connect/auth
  ?response_type=code
  &client_id=web-app
  &redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
  &scope=openid%20profile%20email
  &state=Zq3v8sample7KpW2
  &nonce=n0nceSample4xQ
  &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
  &code_challenge_method=S256
Sample redirect back to the app
HTTP/1.1 302 Found
Location: https://app.example.com/callback?state=Zq3v8sample7KpW2&code=SAMPLE_CODE

The URL is shown on several lines for reading. In practice it is one line, and every value is percent-encoded.

What this tool does

  • Builds Keycloak’s authorization endpoint from a server URL and a realm, or takes any custom endpoint.
  • Makes a random state, nonce and PKCE code verifier in your browser, and computes the S256 challenge.
  • Lets you set response_type, scope, response_mode, prompt, login_hint and kc_idp_hint.
  • Accepts extra parameters as name=value lines, for anything the form does not cover.
  • Percent-encodes every value and lists the parameters one per row.
  • Warns about the implicit flow, missing PKCE, a missing openid scope and plain http redirects.
  • Shows the code verifier you must keep for the token request.

The Open in a new tab button sends your browser to the URL, which is exactly what your app would do. Nothing passes through us.

What it does not do

It does not know your client’s registered redirect URIs, so it cannot tell whether the server will accept the one you typed. Check that with the redirect URI matcher. It also does not sign request objects or push the request to the server; for that, use the PAR request builder.

How to build a URL step by step

  1. Enter your Keycloak server URL, without /realms/, and the realm name. Or switch to Custom URL and paste any authorization endpoint.
  2. Enter the client_id and redirect_uri exactly as registered on the client.
  3. Keep response_type on code and PKCE turned on.
  4. Edit the scopes. Keep openid if you want an ID token.
  5. Set prompt, login_hint or kc_idp_hint if your test needs them.
  6. Copy the URL or open it. Copy the code verifier too.
  7. After sign-in, read the callback with the callback URL parser, then exchange the code with the token request builder.

Encoding the URL correctly

Each parameter value must be percent-encoded, because it sits inside a URL. The redirect URI is the value that most often goes wrong, since it is itself a URL full of : and / characters.

  • Spaces between scopes become %20. Many servers also accept + in the query, but %20 is unambiguous.
  • Encode each value once. Double encoding turns %2F into %252F and the server sees a different redirect URI.
  • Do not encode the = and & that separate parameters.
  • Do not worry about order. Servers read parameters by name.
  • Send each parameter only once. A repeated parameter makes the request invalid.

Libraries such as URLSearchParams in the browser handle this for you. The tool uses the same rules, so its output is a good reference when your own URL looks different.

Choosing the response type

Use response_type=code. The server returns a short-lived code in the redirect, and the app trades it for tokens over a direct back-channel request.

The tool also offers token and id_token token, the implicit flow, so you can debug old setups. The implicit flow returns tokens in the URL fragment, where they can leak through browser history, logs and referrer headers. It also cannot use PKCE or sender-constrained tokens. RFC 9700 says clients should not use it. A single-page app should use the code flow with PKCE instead.

Use cases

Testing a new client

Before wiring up a library, build the URL by hand and sign in once. If it works here, the realm and client are set up correctly and any remaining problem is in the app.

Single-page and mobile apps

Public clients rely on PKCE. Build a request with the challenge, then make sure your app sends the matching verifier. RFC 8252 asks mobile and desktop apps to open this URL in the system browser, not an embedded web view.

Forcing a fresh sign-in or a silent check

prompt=login makes the user enter credentials again even with a session. prompt=none asks for a result with no page at all and fails with login_required if there is no session. max_age limits how old the last sign-in may be.

Sending users to one identity provider

When a realm has several identity providers, kc_idp_hint skips Keycloak’s own sign-in page and goes straight to the provider with that alias.

How Keycloak handles the request

Keycloak’s authorization endpoint is https://<host>/realms/<realm>/protocol/openid-connect/auth. Every realm has its own. Servers on very old versions, or set up with a path, have it under that path, such as /auth/realms/<realm>/....

Keycloak checks the client_id and the redirect_uri first. If the redirect URI does not match one of the client’s Valid redirect URIs, it shows an error page with Invalid parameter: redirect_uri instead of redirecting. That is deliberate: it will not send a result to an address it does not trust.

The client must have Standard flow turned on for response_type=code. A client can also be set to require PKCE with S256, in which case requests without a challenge fail.

Common errors and how to fix them

What you seeCauseFix
Invalid parameter: redirect_uriThe URI does not match a registered oneRegister the exact URI, or test it with the redirect URI matcher
Client not foundWrong client_id, or the wrong realmCheck both; ids are case-sensitive
unauthorized_clientThe flow is turned off for the clientUse code and turn on Standard flow
invalid_scopeA scope that is not assigned to the clientAdd it as a client scope, or remove it
login_requiredprompt=none and no sessionSend the user through a normal sign-in

Look up any other code in the OAuth error lookup.

Security notes

  • Use the code flow with PKCE for every client, as RFC 9700 recommends.
  • Register exact redirect URIs and use https outside localhost.
  • Make state, nonce and the verifier fresh for each request and keep them in the session.
  • Never put a client secret or a token in the authorization URL. It is visible to the browser.
  • Treat login_hint and other hints as untrusted input on the server side.
Questions

Frequently asked questions

What is the Keycloak authorization endpoint URL?

It is https://<host>/realms/<realm>/protocol/openid-connect/auth. You can also read it from the realm’s discovery document at /realms/<realm>/.well-known/openid-configuration.

Why does Keycloak show Invalid parameter: redirect_uri?

The redirect_uri in the request does not match any of the client’s Valid redirect URIs. Matching is exact, except for a * at the very end of an entry. Fix the entry or the URI your app sends.

Do I need the openid scope?

Only for OpenID Connect. Without openid the request is plain OAuth 2.0 and no ID token comes back. If you want to know who signed in, include it.

Should I URL-encode the redirect_uri?

Yes. Every query value must be percent-encoded, so https://app.example.com/callback becomes https%3A%2F%2Fapp.example.com%2Fcallback. The server decodes it before comparing.

What does kc_idp_hint do?

It is a Keycloak parameter. Set it to an identity provider’s alias and Keycloak skips its own sign-in page and sends the user straight to that provider.

What is response_mode=form_post?

The server returns the result as an HTML form that posts to your redirect URI, instead of putting it in the URL. It keeps the code out of the address bar and history. Your callback must accept POST.

Can I add custom parameters to the authorization URL?

Yes. Servers ignore parameters they do not know, and some define their own. Use the extra parameters box here to add them one per line.

Why is there no code in my callback URL?

Look for error and error_description in the URL instead; the server reports failures there. If the URL has a #fragment, the response mode was fragment and the code is after the #. If the page never redirected, Keycloak probably rejected the redirect_uri.

Is the implicit flow still supported?

Many servers still accept it, including Keycloak when Implicit flow is turned on for a client. RFC 9700 says not to use it because tokens leak through the URL. Use the code flow with PKCE.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.