![]() |
VOOZH | about |
dotnet add package Schick.Keycloak.RestApiClient --version 26.5.7
NuGet\Install-Package Schick.Keycloak.RestApiClient -Version 26.5.7
<PackageReference Include="Schick.Keycloak.RestApiClient" Version="26.5.7" />
<PackageVersion Include="Schick.Keycloak.RestApiClient" Version="26.5.7" />Directory.Packages.props
<PackageReference Include="Schick.Keycloak.RestApiClient" />Project file
paket add Schick.Keycloak.RestApiClient --version 26.5.7
#r "nuget: Schick.Keycloak.RestApiClient, 26.5.7"
#:package Schick.Keycloak.RestApiClient@26.5.7
#addin nuget:?package=Schick.Keycloak.RestApiClient&version=26.5.7Install as a Cake Addin
#tool nuget:?package=Schick.Keycloak.RestApiClient&version=26.5.7Install as a Cake Tool
This is a .NET / C# REST API client
| Keycloak.RestApiClient | Keycloak |
|---|---|
| 26.n.n | 26.x.x |
| ... | ... |
| 19.n.n | 19.x.x |
Install from NuGet package
Install-Package Schick.Keycloak.RestApiClient
Method names are humanized:
GET on path /{realm}/users becomes GetUsers(Async)
GET on path /{realm}/identity-provider/providers/{provider_id} becomes GetIdentityProviderProvidersByProviderId(Async)
You can select authentication flow either by the username and password or by providing client ID and client secret.
With authentication by username/password
using FS.Keycloak.RestApiClient.Api;
using FS.Keycloak.RestApiClient.Authentication.ClientFactory;
using FS.Keycloak.RestApiClient.Authentication.Flow;
using FS.Keycloak.RestApiClient.ClientFactory;
var credentials = new PasswordGrantFlow
{
KeycloakUrl = "https://<keycloak-url>",
Realm = "<realm>",
UserName = "<username>",
Password = "<password>"
};
using var httpClient = AuthenticationHttpClientFactory.Create(credentials);
using var usersApi = ApiClientFactory.Create<UsersApi>(httpClient);
var users = await usersApi.GetUsersAsync("<realm>");
Console.WriteLine($"Users: {users.Count}");
With authentication by client-id/client-secret
using FS.Keycloak.RestApiClient.Api;
using FS.Keycloak.RestApiClient.Authentication.ClientFactory;
using FS.Keycloak.RestApiClient.Authentication.Flow;
using FS.Keycloak.RestApiClient.ClientFactory;
var credentials = new ClientCredentialsFlow
{
KeycloakUrl = "https://<keycloak-url>",
Realm = "<realm>",
ClientId = "<client-id>",
ClientSecret = "<client-secret>"
};
using var httpClient = AuthenticationHttpClientFactory.Create(credentials);
using var usersApi = ApiClientFactory.Create<UsersApi>(httpClient);
var users = await usersApi.GetUsersAsync("<realm>");
Console.WriteLine($"Users: {users.Count}");
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;
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 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Schick.Keycloak.RestApiClient:
| Package | Downloads |
|---|---|
|
Nvx.ConsistentAPI.TestUtils
Test helpers for the Event Modeling framework Nvx.ConsitentAPI |
|
|
QuickJob.Users.Client
Package Description |
|
|
Be.Auto.Authentication.Keycloak.Role
ASP.NET Core Keycloak Integration |
|
|
Boxty.ServerBase
Server-side infrastructure for building multi-tenant APIs with Keycloak authentication |
|
|
Be.Auto.Servicestack.Authentication.Keycloak
Servicestack Keycloak Role Based Authentication |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.5.7 | 21,900 | 4/11/2026 |
| 26.5.3 | 44,153 | 2/11/2026 |
| 26.4.2 | 78,649 | 10/30/2025 |
| 26.2.0 | 242,148 | 4/15/2025 |
| 26.1.2 | 36,666 | 2/12/2025 |
| 26.0.7 | 39,625 | 12/31/2024 |
| 26.0.6 | 32,870 | 12/2/2024 |
| 26.0.2 | 43,496 | 10/24/2024 |
| 26.0.0 | 3,341 | 10/18/2024 |
| 25.0.0 | 214,941 | 6/23/2024 |
| 24.0.2 | 45,147 | 6/7/2024 |
| 24.0.2-beta1 | 205 | 6/6/2024 |
| 24.0.1 | 17,349 | 4/23/2024 |
| 24.0.0 | 653 | 4/20/2024 |
| 23.0.1 | 2,624 | 4/23/2024 |
| 23.0.0 | 1,025 | 4/20/2024 |
| 22.0.3 | 115,411 | 11/5/2023 |