Table of Contents

Interface IKeycloakUserClient

Namespace
Keycloak.AuthServices.Sdk.Admin
Assembly
Keycloak.AuthServices.Sdk.dll

User management

public interface IKeycloakUserClient

Methods

CreateUserAsync(string, UserRepresentation, CancellationToken)

Create a new user.

Task CreateUserAsync(string realm, UserRepresentation user, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

user UserRepresentation

User representation.

cancellationToken CancellationToken

Returns

Task

Remarks

Username must be unique.

CreateUserWithResponseAsync(string, UserRepresentation, CancellationToken)

Create a new user.

Task<HttpResponseMessage> CreateUserWithResponseAsync(string realm, UserRepresentation user, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

user UserRepresentation

User representation.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Remarks

Username must be unique.

DeleteUserAsync(string, string, CancellationToken)

Delete the given user.

Task DeleteUserAsync(string realm, string userId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

cancellationToken CancellationToken

Returns

Task

DeleteUserWithResponseAsync(string, string, CancellationToken)

Delete the given user.

Task<HttpResponseMessage> DeleteUserWithResponseAsync(string realm, string userId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

ExecuteActionsEmailAsync(string, string, ExecuteActionsEmailRequest, CancellationToken)

Execute actions email for the user.

Task ExecuteActionsEmailAsync(string realm, string userId, ExecuteActionsEmailRequest request, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

request ExecuteActionsEmailRequest
cancellationToken CancellationToken

Returns

Task

ExecuteActionsEmailWithResponseAsync(string, string, ExecuteActionsEmailRequest, CancellationToken)

Execute actions email for the user.

Task<HttpResponseMessage> ExecuteActionsEmailWithResponseAsync(string realm, string userId, ExecuteActionsEmailRequest request, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

request ExecuteActionsEmailRequest
cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

GetUserAsync(string, string, bool, CancellationToken)

Get representation of a user.

Task<UserRepresentation> GetUserAsync(string realm, string userId, bool includeUserProfileMetadata = false, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

includeUserProfileMetadata bool

Indicates if the user profile metadata should be added to the response.

cancellationToken CancellationToken

Returns

Task<UserRepresentation>

The user representation.

GetUserGroupsAsync(string, string, GetUserGroupsRequestParameters?, CancellationToken)

Get a users's groups.

Task<IEnumerable<GroupRepresentation>> GetUserGroupsAsync(string realm, string userId, GetUserGroupsRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

parameters GetUserGroupsRequestParameters

Optional query parameters.

cancellationToken CancellationToken

Returns

Task<IEnumerable<GroupRepresentation>>

A stream of users, filtered according to query parameters.

GetUserGroupsWithResponseAsync(string, string, GetUserGroupsRequestParameters?, CancellationToken)

Get a users's groups.

Task<HttpResponseMessage> GetUserGroupsWithResponseAsync(string realm, string userId, GetUserGroupsRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

parameters GetUserGroupsRequestParameters

Optional query parameters.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

A stream of users, filtered according to query parameters.

GetUserWithResponseAsync(string, string, bool, CancellationToken)

Get representation of a user.

Task<HttpResponseMessage> GetUserWithResponseAsync(string realm, string userId, bool includeUserProfileMetadata = false, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

includeUserProfileMetadata bool

Indicates if the user profile metadata should be added to the response.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

The user representation.

GetUsersAsync(string, GetUsersRequestParameters?, CancellationToken)

Get a stream of users on the realm.

Task<IEnumerable<UserRepresentation>> GetUsersAsync(string realm, GetUsersRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

parameters GetUsersRequestParameters

Optional query parameters.

cancellationToken CancellationToken

Returns

Task<IEnumerable<UserRepresentation>>

A stream of users, filtered according to query parameters.

GetUsersWithResponseAsync(string, GetUsersRequestParameters?, CancellationToken)

Get a stream of users on the realm.

Task<HttpResponseMessage> GetUsersWithResponseAsync(string realm, GetUsersRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

parameters GetUsersRequestParameters

Optional query parameters.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

A stream of users, filtered according to query parameters.

JoinGroupAsync(string, string, string, CancellationToken)

Join a group

Task JoinGroupAsync(string realm, string userId, string groupId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name(not ID).

userId string

User ID.

groupId string

Group ID.

cancellationToken CancellationToken

Returns

Task

JoinGroupWithResponseAsync(string, string, string, CancellationToken)

Join a group

Task<HttpResponseMessage> JoinGroupWithResponseAsync(string realm, string userId, string groupId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name(not ID).

userId string

User ID.

groupId string

Group ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

LeaveGroupAsync(string, string, string, CancellationToken)

Leave a group

Task LeaveGroupAsync(string realm, string userId, string groupId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name(not ID).

userId string

User ID.

groupId string

Group ID.

cancellationToken CancellationToken

Returns

Task

LeaveGroupWithResponseAsync(string, string, string, CancellationToken)

Leave a group

Task<HttpResponseMessage> LeaveGroupWithResponseAsync(string realm, string userId, string groupId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name(not ID).

userId string

User ID.

groupId string

Group ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

SendVerifyEmailAsync(string, string, string?, string?, CancellationToken)

Send an email-verification email to the user.

Task SendVerifyEmailAsync(string realm, string userId, string? clientId = null, string? redirectUri = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

clientId string

Client ID.

redirectUri string

Redirect URI. The default for the redirect is the account client.

cancellationToken CancellationToken

Returns

Task

Remarks

An email contains a link the user can click to verify their email address.

SendVerifyEmailWithResponseAsync(string, string, string?, string?, CancellationToken)

Send an email-verification email to the user.

Task<HttpResponseMessage> SendVerifyEmailWithResponseAsync(string realm, string userId, string? clientId = null, string? redirectUri = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

clientId string

Client ID.

redirectUri string

Redirect URI. The default for the redirect is the account client.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Remarks

An email contains a link the user can click to verify their email address.

UpdateUserAsync(string, string, UserRepresentation, CancellationToken)

Update the user.

Task UpdateUserAsync(string realm, string userId, UserRepresentation user, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

user UserRepresentation

User representation.

cancellationToken CancellationToken

Returns

Task

UpdateUserWithResponseAsync(string, string, UserRepresentation, CancellationToken)

Update the user.

Task<HttpResponseMessage> UpdateUserWithResponseAsync(string realm, string userId, UserRepresentation user, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

userId string

User ID.

user UserRepresentation

User representation.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>