Dynamic Client Registration
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" }});
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;