| title | Dynamic Client Registration | ||||
|---|---|---|---|---|---|
| description | Documentation for OpenID Connect Dynamic Client Registration library extension method for HttpClient that enables client registration and response handling | ||||
| sidebar |
|
||||
| redirect_from |
|
The client library for OpenID Connect Dynamic Client Registration
is provided as an extension method for
System.Net.Http.HttpClient.
The following code sends a registration request:
var client = new HttpClient();
var response = await client.RegisterClientAsync(new DynamicClientRegistrationRequest
{
Address = Endpoint,
Document = new DynamicClientRegistrationDocument
{
RedirectUris = { redirectUri },
ApplicationType = "native"
}
});:::note The DynamicClientRegistrationDocument class has strongly typed properties for all standard registration parameters as defines by the specification. If you want to add custom parameters, it is recommended to derive from this class and add your own properties. :::
The response is of type RegistrationResponse and has properties for the standard response parameters. You also have access to the raw response and to a parsed JSON document (via the Raw and Json properties).
Before using the response, you should always check the IsError property to make sure the request was successful:
if (response.IsError) throw new Exception(response.Error);
var clientId = response.ClientId;
var secret = response.ClientSecret;