Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get user ID from custom attributes? #554

Open
chung1912 opened this issue Apr 16, 2024 · 3 comments
Open

How to get user ID from custom attributes? #554

chung1912 opened this issue Apr 16, 2024 · 3 comments

Comments

@chung1912
Copy link

I know the way to get user ID from username is as follows:
user_id_keycloak = keycloak_admin.get_user_id("username-keycloak")

How to get user ID from custom attributes?

@carbonleakage
Copy link

Have you already tried the get_users method?

@ggrames
Copy link

ggrames commented Nov 18, 2024

I am also interested how to get the userid via custom attribute.
Have you already a solution?

@ryshoooo
Copy link
Collaborator

You should be able to use the get_users method, f.e. if you want to find a user with custom attribute key "my-custom-attr-1" having a value "my-value", you could do

keycloak_admin.get_users(query={"q": "my-custom-attr-1:my-value"})

You can check the docs at https://www.keycloak.org/docs-api/latest/rest-api/index.html#_users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants