Skip to content

OIDC UserInfo request builder

Build the request that reads the signed-in user’s claims from the OpenID Connect UserInfo endpoint, with a Bearer or DPoP token.

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.

An access token issued with the openid scope. A placeholder is filled in.

How to send it
Token type

UserInfo request

curl command
curl 'https://auth.example.com/realms/acme/protocol/openid-connect/userinfo' \
  -H 'Authorization: Bearer SAMPLE_ACCESS_TOKEN'
Sample response (made-up values)
{
  "sub": "1f8f4b3a-sample",
  "email_verified": true,
  "name": "Alice Example",
  "preferred_username": "alice",
  "given_name": "Alice",
  "family_name": "Example"
}
Check sub
The sub in the response must equal the sub in the ID token; if not, do not use the response (OpenID Connect Core 5.3.2). Which other claims come back depends on the scopes and the client’s mappers.
A 401 with invalid_token in the WWW-Authenticate header usually means the token expired or comes from another realm.

How to use it

  1. Enter your Keycloak server URL and realm, or a custom UserInfo endpoint.
  2. Paste an access token issued with the openid scope.
  3. Choose GET or POST, and Bearer or DPoP.
  4. Copy the request.

What to know

The UserInfo endpoint returns claims about the user the access token belongs to. In Keycloak it is https://<host>/realms/<realm>/protocol/openid-connect/userinfo.

Send the token in the Authorization header. Sending it in a form body is allowed only when a header is impossible.

The response always has sub, which must equal the sub in the ID token. Other claims depend on the scopes granted and the client’s mappers.

What the UserInfo endpoint is

The UserInfo endpoint returns claims about the user who signed in: their name, email, locale and whatever else the client was allowed to see. It is part of OpenID Connect Core 1.0, section 5.3. The client calls it with the access token it received after sign-in.

It exists because the ID token is meant to be small. The ID token proves who signed in and when. Profile details can live in the ID token, at UserInfo, or both, depending on how the provider is set up. UserInfo also gives you current values, read at the moment you ask.

From OAuth’s point of view, UserInfo is just a protected resource. The access token is a bearer token, sent as RFC 6750 describes, and the server answers with JSON.

How a UserInfo request works

The client sends GET or POST to the endpoint with the access token in the Authorization header. The token must come from an OpenID Connect request, which means the openid scope was part of it.

Sample request (made-up host and token)
GET /realms/acme/protocol/openid-connect/userinfo HTTP/1.1
Host: auth.example.com
Authorization: Bearer SAMPLE_ACCESS_TOKEN
Sample response (made-up values)
HTTP/1.1 200 OK
Content-Type: application/json

{
  "sub": "1f8f4b3a-sample",
  "name": "Alice Example",
  "preferred_username": "alice",
  "given_name": "Alice",
  "family_name": "Example"
}

The response always contains sub. Which other claims appear depends on the scopes the user granted, such as profile, email, address or phone, and on how the server maps them. If the client registered for signed or encrypted UserInfo responses, the body is a JWT with the content type application/jwt instead of plain JSON.

Ways to send the token

MethodHowWhen
GET with headerAuthorization: Bearer <token>The default. Use this.
POST with headerSame header, empty bodyWhen a client library prefers POST.
POST with form bodyaccess_token=<token> in the bodyOnly when headers are impossible (RFC 6750 section 2.2).
DPoP-bound tokenAuthorization: DPoP <token> plus a DPoP proof headerWhen the token is bound to a key (RFC 9449).

What this tool does

The tool builds the UserInfo request and shows it as a curl command and as the raw HTTP request. It does not send anything; the token stays in your browser.

  • It builds Keycloak’s UserInfo endpoint from a server URL and realm, or uses any custom URL.
  • It sends the token as GET with a header, POST with a header, or POST in a form body.
  • For DPoP-bound tokens it uses the DPoP scheme and adds the proof header you paste in.
  • It shows a made-up sample response and explains the sub check.

It does not create a DPoP proof; make one with the DPoP proof generator. It does not decode or validate the access token either; the JWT decoder reads its claims.

How to use the tool

  1. Enter your Keycloak server URL and realm, or switch to Custom URL and paste the userinfo_endpoint from the discovery document.
  2. Paste an access token that was issued with the openid scope.
  3. Choose how to send it. Leave it on GET with a header unless you have a reason not to.
  4. If the token is DPoP-bound, switch the token type to DPoP and paste a fresh proof for this method and URL.
  5. Copy the curl command and run it, or read the HTTP view.
  6. Compare sub in the response with sub in the ID token before using any other claim.

UserInfo in Keycloak

In Keycloak the endpoint is https://<host>/realms/<realm>/protocol/openid-connect/userinfo. It is listed as userinfo_endpoint in the realm’s discovery document, which the OIDC discovery viewer can show you.

Which claims appear is decided by protocol mappers in the client scopes the token carries. Each mapper has its own switches for adding the claim to the ID token, the access token and UserInfo. If a claim is in the ID token but missing from UserInfo, or the other way round, check that mapper’s Add to userinfo setting.

Keycloak’s built-in profile and email client scopes map the standard OpenID Connect claims. The OIDC claims reference lists which scope gives which claim, and the scope builder helps you write the scope parameter.

When to call UserInfo

Web apps with a back end

After the token exchange, the server can read the user’s profile from the ID token and call UserInfo only for claims it does not find there. Call it again later if you need current values, for example to refresh a cached display name.

Single-page apps

A browser app can call UserInfo directly with its access token. In Keycloak, the client’s Web origins must allow the app’s origin so the browser may read the response. Keep the token in memory rather than in local storage.

Mobile and desktop apps

Native apps often call UserInfo once after sign-in to fill a profile screen. Keep the access token in the platform’s secure storage, and compare sub with the ID token as every client should.

APIs

An API that receives an access token can call UserInfo with it to learn about the user. Often it is simpler to put the needed claims in the access token itself, or to use introspection, which the introspection request builder builds.

Common errors and how to fix them

401 with invalid_token

RFC 6750 says the error comes back in the WWW-Authenticate response header, for example Bearer error="invalid_token". Common causes:

  • The access token expired. Refresh it and try again.
  • The token comes from another realm or server than the endpoint you call.
  • The header is malformed: a missing Bearer prefix, a doubled one, or quotes around the token.
  • The user’s session ended, for example after logout.

403 with insufficient_scope

The token is valid but was not issued for this use. Make sure the authorization request asked for openid, and for the scopes whose claims you expect.

Claims are missing

The scope was not requested or not granted, the user has no value for that attribute, or no mapper adds the claim to UserInfo. Decode the access token and check its scope claim first.

Security notes

  • Check sub. OpenID Connect Core 5.3.2 says the sub in the UserInfo response must equal the sub in the ID token, or the response must not be used. This protects against token substitution.
  • Send the token in the header, not in the URL. Tokens in query strings end up in logs and browser history.
  • Do not use email or preferred_username as the user’s key. They can change and can be reused. Use iss together with sub.
  • Only trust email when email_verified is true, if you use the email for anything that matters.
  • RFC 9700, the OAuth security best current practice, recommends sender-constrained tokens where possible. DPoP is one way to do that; a DPoP-bound token is sent with the DPoP scheme and a fresh proof.

Best practices

  • Read what you need from the ID token first; call UserInfo only for the rest.
  • Ask for the smallest set of scopes that gives you the claims you use.
  • Cache the result for the length of your own session rather than calling on every page.
  • Handle 401 by refreshing the token once, then sending the user through sign-in.

If you would rather have someone else run the Keycloak behind this endpoint, see our pricing for managed realms on a dedicated cluster.

Questions

Frequently asked questions

What is the Keycloak UserInfo endpoint URL?

`https://<host>/realms/<realm>/protocol/openid-connect/userinfo`. Each realm has its own, listed as `userinfo_endpoint` in its discovery document.

Should I use GET or POST for UserInfo?

Either works; OpenID Connect allows both. GET with the token in the Authorization header is the usual choice. Put the token in a POST body only when you cannot set headers.

Why does UserInfo return 401?

The token expired, comes from another realm, or was sent without the `Bearer ` prefix. Read the `WWW-Authenticate` response header; it names the error. Refresh the token and try again.

Why is a claim missing from the UserInfo response?

Its scope was not requested or granted, the user has no value for it, or the mapper does not add it to UserInfo. In Keycloak, check the client scope’s mapper and its Add to userinfo setting.

Do I need the openid scope to call UserInfo?

Yes. UserInfo belongs to OpenID Connect, and the access token must come from an OpenID Connect request, which includes `openid`. A plain OAuth token is not meant for it.

Should I call UserInfo or read the ID token?

Start with the ID token; it often has what you need. Call UserInfo for claims that are not in it, or when you want current values. Always compare `sub` between the two.

Can a single-page app call UserInfo directly?

Yes, with its access token. In Keycloak, set Web origins on the client so the browser may read Keycloak’s responses from your app’s origin.

Is the UserInfo response signed?

Usually not: it is plain JSON, protected by https. OpenID Connect lets a client register `userinfo_signed_response_alg` to receive a signed JWT instead, with the content type `application/jwt`. Your library must then verify it like an ID token.

How do I call UserInfo with a DPoP-bound token?

Send `Authorization: DPoP <token>` and a `DPoP` header with a fresh proof for this method and URL. The proof must include `ath`, the hash of the access token.

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.