Schick.Keycloak.RestApiClient
20.0.3
See the version list below for details.
dotnet add package Schick.Keycloak.RestApiClient --version 20.0.3
NuGet\Install-Package Schick.Keycloak.RestApiClient -Version 20.0.3
<PackageReference Include="Schick.Keycloak.RestApiClient" Version="20.0.3" />
<PackageVersion Include="Schick.Keycloak.RestApiClient" Version="20.0.3" />
<PackageReference Include="Schick.Keycloak.RestApiClient" />
paket add Schick.Keycloak.RestApiClient --version 20.0.3
#r "nuget: Schick.Keycloak.RestApiClient, 20.0.3"
#addin nuget:?package=Schick.Keycloak.RestApiClient&version=20.0.3
#tool nuget:?package=Schick.Keycloak.RestApiClient&version=20.0.3
.NET / C# Keycloak.RestApiClient
This is a .NET / C# REST API client
- for the Keycloak Admin REST API
- auto-generated by OpenAPI Generator
- using the OpenAPI definitions generated by Keycloak OpenApi Generator
Documentation for API Endpoints
- Official documentation: Keycloak Admin REST API
- Generated Swagger UI: Swagger Editor
Keycloak versions supported
Keycloak.RestApiClient | Keycloak |
---|---|
19.n.n | 19.x.x |
20.n.n | 20.x.x |
Frameworks supported
- .NET Core >=1.0
- .NET Framework >=4.6
- Mono/Xamarin >=vNext
Installation
Install from NuGet package
Install-Package Schick.Keycloak.RestApiClient
Getting Started
Method names
Method names are humanized:
GET
on path /{realm}/users
becomes GetUsers(Async)
GET
on path /{realm}/identity-provider/providers/{provider_id}
becomes GetIdentityProviderProvidersByProviderId(Async)
Sample code
using FS.Keycloak.RestApiClient.Api;
using FS.Keycloak.RestApiClient.Client;
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
internal class Program
{
private static async Task Main(string[] args)
{
using var httpClient = new KeycloakHttpClient("<authServerUrl>", "<admin_user>", "<password>");
using var usersApi = ApiClientFactory.Create<UsersApi>(httpClient);
var users = await usersApi.GetUsersAsync("MyRealm");
Console.WriteLine($"Users: {users.Count}");
}
}
}
Advanced Usage
To use the API client with a HTTP proxy, setup a System.Net.WebProxy
Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
Connections
Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method.
To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see here for details). To use your own HttpClient instance just pass it to the ApiClass constructor.
HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);
If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory.
HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient);
You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available.
Here an example of DI setup in a sample web project:
services.AddHttpClient<YourApiClass>(httpClient =>
new PetApi(httpClient));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- JsonSubTypes (>= 1.9.0)
- Newtonsoft.Json (>= 13.0.1)
- Polly (>= 7.2.3)
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Schick.Keycloak.RestApiClient:
Package | Downloads |
---|---|
QuickJob.Users.Client
Package Description |
|
Be.Auto.Authentication.Keycloak.Role
ASP.NET Core Keycloak Integration |
|
Be.Auto.Servicestack.Authentication.Keycloak
Servicestack Keycloak Role Based Authentication |
|
Keycloak.Authz.Net.Resources
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
26.2.0 | 535 | 4/15/2025 |
26.1.2 | 16,406 | 2/12/2025 |
26.0.7 | 9,821 | 12/31/2024 |
26.0.6 | 24,046 | 12/2/2024 |
26.0.2 | 25,967 | 10/24/2024 |
26.0.0 | 2,706 | 10/18/2024 |
25.0.0 | 119,199 | 6/23/2024 |
24.0.2 | 40,490 | 6/7/2024 |
24.0.2-beta1 | 112 | 6/6/2024 |
24.0.1 | 13,121 | 4/23/2024 |
24.0.0 | 330 | 4/20/2024 |
23.0.1 | 1,107 | 4/23/2024 |
23.0.0 | 257 | 4/20/2024 |
22.0.3 | 83,157 | 11/5/2023 |
22.0.2 | 275 | 11/4/2023 |
22.0.1 | 911 | 10/24/2023 |
22.0.0 | 2,268 | 10/3/2023 |
21.0.0 | 92,046 | 4/26/2023 |
20.0.3 | 8,313 | 2/22/2023 |
20.0.2 | 286 | 2/18/2023 |
20.0.1 | 357 | 12/30/2022 |
19.0.2 | 437 | 12/24/2022 |
19.0.1 | 366 | 11/7/2022 |
19.0.0 | 665 | 11/4/2022 |