Skip to content

POST logout() gets error 'invalid parameter id_token_hint' from server, when the user already has been unauthenticated #287

Open

Description

@sandrstack

Describe the bug

When calling the logout() method using the POST method option and the Keycloak session has already been expired and user has already been unauthenticated (the idToken has been removed), the Keycloak server returns with an error invalid parameter id_token_hint. Calling the method using the GET method option, Keycloak does not respond with an error.

The cause is a different checking of the current idToken. With the GET logout method the parameter id_token_hint is only added to the url, if the idToken is actually present and defined.
With the POST logout method the parameter id_token_hint is always added to the form data, even if the idToken is not present and undefined. There is no check, if the idToken is present.

Version

26.5.6

Expected behavior

When calling POST logout() in an expired session and the user is already unauthenticated, the parameter id_token_hint with its value undefined should be omitted from the request data, like GET logout() does.

POST data:

// Add data to form as hidden input fields.
// Match behavior of createLogoutUrl() for GET requests.
  const data = {
  client_id: this.clientId,
  post_logout_redirect_uri: redirectUri(options)
}
// Only add id token parameter when it is present to avoid error 'invalid id token hint'
if (this.idToken) {
  data.id_token_hint = this.idToken
}

Actual behavior

When calling POST logout() with an expired session and the user is already unauthenticated, the parameter id_token_hint with its value undefined is present in the request data and is not filtered, resulting in the described error.

POST data:

// Add data to form as hidden input fields.
const data = {
  id_token_hint: this.idToken,
  client_id: this.clientId,
  post_logout_redirect_uri: redirectUri(options)
}

How to Reproduce?

Use and call the POST logout() method with an expired session and the user has already been unauthenticated.

Anything else?

No response

Activity

  1. added a commit that references this issue on Mar 26, 2026
    7c8c01b
  2. sparqueur commented on Jun 26, 2026

    @sparqueur

    Any news ? We have the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions