Table of Contents

Class HttpResponseExtensions

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

Provides extension methods for handling HTTP responses.

public static class HttpResponseExtensions
Inheritance
HttpResponseExtensions
Inherited Members

Methods

EnsureResponseAsync(HttpResponseMessage, CancellationToken)

Ensures that the HTTP response is successful, otherwise throws an exception.

public static Task EnsureResponseAsync(this HttpResponseMessage response, CancellationToken cancellationToken = default)

Parameters

response HttpResponseMessage

The HTTP response message.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

Exceptions

KeycloakHttpClientException

Thrown when the response is not successful.

GetResponseAsync<T>(HttpResponseMessage, CancellationToken)

Reads the HTTP response content as JSON and deserializes it into the specified type.

public static Task<T?> GetResponseAsync<T>(this HttpResponseMessage response, CancellationToken cancellationToken = default)

Parameters

response HttpResponseMessage

The HTTP response message.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<T>

The deserialized response content.

Type Parameters

T

The type to deserialize the response content into.