Understanding the "JWT is not valid for this realm" error when configuring SSO on Neo4jApr 14, 2026Knowledge
Article DetailsDetailsHelp DetailsIn the context of Single Sign-On (SSO) authentication, the error message "JWT is not valid for this realm" usually indicates an issue with validating the JSON Web Token (JWT) during authentication. Such issues could result from invalid signatures, JWT claims mismatches or other validation errors. Following is an example of a JWT token (steps to capture the JWT token from a browser are detailed here) decoded using jwt.io, demonstrating various claims (exp, iat, etc.) presented in a JWT token: Above shows some common JWT claims, which are described below: Issuer Claim (“iss”): The application which issued the JWTSubject Claim (“sub”): The user subject of the JWTAudience Claim (“aud”): Application which is the JWT intended forExpiration Time Claim (“exp”): Expiry date/time by when the JWT be acceptedNot Before Claim (“nbf”): Time by when the JWT claim could begin to be acceptedIssued At Claim (“iat”): Timestamp of the JWT claim issueJWT ID Claim (“jti”): Identifier of the individual JWT claim Following are some likely causes for the "JWT is not valid for this realm" error: Issuer Mismatch: The JWT issuer (iss) claim does not match the configured issuer for the realm. This means that the identity provider (IdP) that issued the JWT is not recognised or trusted by Neo4j. Incorrect Audience: The audience (aud) claim in the JWT does not match the expected audience for the realm. The audience claim specifies the intended recipient of the JWT, and if it doesn't match the expected value, the JWT is considered invalid for the realm.Missing sub, exp, iat claims: These claims should be present in most JWT tokens from known IdP providers. If they are missing the JWT validation will fail.Missing azp Claim: If there are multiple audience claims (aud) in the JWT, it is important to ensure that the authorized party (azp) claim is set and matches the client_id. Failure to include or match this claim can result in the JWT being rejected.Incorrect x5t / x5t#S256 Usage: The x5t in the JWT header is expected to be a SHA-1 hash of the certificate. If you intend to use a SHA-256 thumbprint, you must use the x5t#S256 field instead. Using SHA-256 in x5t, or mismatching these fields, can lead to key lookup or signature validation failures.KID Not Present in JWKS URL: The Key ID (kid) specified in the JWT header is not present in the JSON Web Key Set (JWKS) URL. The kid is used to identify the cryptographic key used to sign the JWT, and if it's not found in the JWKS, the JWT validation fails with the following error (reported using the DEBUG root logging): "c.n.s.s.e.a.OidcRealm","message":"{OidcRealm: oidc-azure}: Unable to find a suitable verification key for JWS Troubleshooting Steps: Primarily, the idea is to compare the Neo4j SSO configuration with the JWT token claims. Capture the JWT token from the Web Browser. Details are available here.Alternatively, enable JWT claims to be logged in Neo4j server logs, usingdbms.security.logs.oidc.jwt_claims_at_debug_level_enabled.Details are available hereVerify that the issuer (iss) claim in the JWT matches the configured issuer for the realm.Ensure that the audience (aud) claim in the JWT matches the expected audience for the realm.If multiple audience claims are present, verify that the authorized party (azp) claim is set and matches the client_id.Check the JWKS URL to ensure that the Key ID (kid) specified in the JWT header is present and valid.Ensure that x5t contains a SHA-1 certificate thumbprint. If a SHA-256 thumbprint is used, it must be provided in x5t#S256. Any mismatch can prevent proper key resolution and JWT validation.Set security and root loggers to DEBUG level in server-logs.xml for Neo4j 5.x ( for Neo4j 4.x, it is dbms.logs.security.level=DEBUG). InformationTitleUnderstanding the "JWT is not valid for this realm" error when configuring SSO on Neo4jArticle Created Date3/15/2024, 10:54 PMURL Name26599604472211-Understanding-the-JWT-is-not-valid-for-this-realm-error-when-configuring-SSO-on-Neo4jLast Modified Date4/14/2026, 6:40 AM