lvermeulen / Keycloak.Net

C# client for Keycloak 6.x
MIT License
203 stars 120 forks source link

CreateGroupAsync throws 404 not found #51

Closed turowicz closed 3 years ago

turowicz commented 3 years ago

I am getting an error when trying to create a group.

var group = new Keycloak.Net.Models.Groups.Group
{
    Name = name,
    Id = id.ToString(),
    Attributes = new Dictionary<string, IEnumerable<string>>
    {
        { JsonKey, new[] { description } },
        { OwnersKey, new[] { $"{Guid.Empty}" } },
    }
};

await _client.CreateGroupAsync(_realm, group); // throws here
turowicz commented 3 years ago

cc @lvermeulen

turowicz commented 3 years ago

The following works just fine:

await _client.CreateClientAndRetrieveClientIdAsync(_realm, new Keycloak.Net.Models.Clients.Client
{
    Name = name,
    Id = id.ToString(),
    ImplicitFlowEnabled = true,
    RedirectUris = new[] { $"http://localhost" },
    WebOrigins = new[] { new Uri(_url, name.ToAppId()).ToString() },
});

So it looks like that I am unable to add a Group with a specific ID, but I can add a Client with specific ID.

turowicz commented 3 years ago

The documentation says I should be able to add the group with a custom ID, just like when adding a Client:

https://www.keycloak.org/docs-api/5.0/rest-api/index.html#_groups_resource https://www.keycloak.org/docs-api/5.0/rest-api/index.html#_grouprepresentation

turowicz commented 3 years ago

Actually its the keycloak itself that breaks the REST pattern, not this nuget package.