python-keycloak icon indicating copy to clipboard operation
python-keycloak copied to clipboard

create_group returns an empty response

Open corvust opened this issue 4 years ago • 3 comments
trafficstars

Keycloak returns an empty HTTP body on the POST /{realm}/groups call, but includes the new group ID in the Location header. create_group should behave similar to create_user, which reads the new ID from the Location header and returns it.

My current workaround is to make an additional call to get_group_by_path to get the new group ID.

corvust avatar Jan 14 '21 16:01 corvust

I can't make create_group work at all!

  • create_group("new-group-name") give me this error: File "/home/paulm/.local/lib/python3.9/site-packages/keycloak/keycloak_admin.py", line 702, in create_group return raise_error_from_response(data_raw, KeycloakGetError, expected_codes=[201], skip_exists=skip_exists) File "/home/paulm/.local/lib/python3.9/site-packages/keycloak/exceptions.py", line 106, in raise_error_from_response raise error(error_message=message,

  • create_group(name="new-group-name") give me this error: TypeError: create_group() got an unexpected keyword argument 'name'

speculatrix avatar Mar 02 '21 15:03 speculatrix

@speculatrix create_group is expecting a dictionary for payload. Try create_group({"name": "new-group-name"}).

lewisbelcher avatar Mar 18 '21 15:03 lewisbelcher

It's worth noting that the response when creating a subgroup does include new group information:

>>> kc.create_group({"name":"A"}, parent="ab...")
{'id': 'cd...',
 'name': 'A',
 'path': '/hello/A',
 'attributes': {},
 'realmRoles': [],
 'clientRoles': {},
 'subGroups': []}

I second that a similar response should be given when creating a group without a parent.

lewisbelcher avatar Mar 18 '21 15:03 lewisbelcher