keycloak-nodejs-admin-client icon indicating copy to clipboard operation
keycloak-nodejs-admin-client copied to clipboard

No group assigned while creating a user

Open Ismaestro opened this issue 5 years ago • 5 comments

Describe the bug When I try to create a user with a group by default, it does not work.

To Reproduce Steps to reproduce the behavior:

  1. What API did you use? I just:
  • Installed keycloack in local, configured it and created an example realm and group
  • Created the example that is in your readme
  • Added groups to the create method...
  • Everything works except the group is not assigned
  1. What error message did you see? No error is showed, the user is created but no group is assigned
  2. Give us a minimum code example
await kcAdminClient.users.create({
        realm: 'realm-test',
        username: 'username',
        email: '[email protected]',
        groups: ['group-test'],
        enabled: true
    });

Expected behavior To create the user but with the group assigned

Screenshots NA

Enviroment (please complete the following information):

  • OS: [e.g. Ubuntu] MacOS Catalina
  • Keycloak Version 8.0
  • Library Version [e.g. 1.9.0] lastest

Additional context NA

Thanks! Isma

Ismaestro avatar Jan 08 '20 15:01 Ismaestro

+1

I've also tried using the groupId but it does not seem to be working.

await kcAdminClient.users.create({
        username: 'username',
        email: '[email protected]',
        groups: ['4aedc1c8-9f60-4125-81e3-9cc7c8ca8238'],
        enabled: true
    });

lucashenning avatar Jun 23 '20 20:06 lucashenning

+1

raj-katonic avatar Jun 25 '21 13:06 raj-katonic

+1

karimerrahli avatar Jan 24 '22 13:01 karimerrahli

I was success usign your example @Ismaestro.

leandrodaf avatar Feb 16 '22 17:02 leandrodaf

To have this work, I ended up using the path of the group instead and it works.

For e.g.

const path = '/Kunden/Hauptbenutzer/example'

await client.users.create({
      username: 'testat',
      email: '[email protected]',
      emailVerified: true,
      enabled: true,
      groups: [path]
    })

adnanchang avatar Jun 16 '22 09:06 adnanchang