OpenID Connect動態客戶端註冊的客戶端庫是做爲HttpClient
擴展方法提供的。html
如下代碼發送註冊請求:git
var client = new HttpClient(); var response = await client.RegisterClientAsync(new DynamicClientRegistrationRequest { Address = Endpoint, RegistrationRequest = new RegistrationRequest { RedirectUris = { redirectUri }, ApplicationType = "native" } });
注意
RegistrationRequest類已經強類型用於全部標準登記參數性質如由規範定義。若是要添加自定義參數,建議今後類派生並添加本身的屬性。github
響應屬於RegistrationResponse
類型並具備標準響應參數的屬性。您還能夠訪問原始響應以及解析的JSON文檔(經過Raw
和Json
屬性)。c#
在使用響應以前,您應該始終檢查IsError
屬性以確保請求成功:.net
if (response.IsError) throw new Exception(response.Error); var clientId = response.ClientId; var secret = resopnse.ClientSecret;
github地址code