public async Task <Core.Common.DTOs.ClientRegistrationResponse> ExecuteAsync(Core.Common.DTOs.Client client, Uri requestUri, string authorizationValue) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (requestUri == null) { throw new ArgumentNullException(nameof(requestUri)); } var httpClient = _httpClientFactory.GetHttpClient(); var json = JsonConvert.SerializeObject(client, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var request = new HttpRequestMessage { Method = HttpMethod.Post, Content = new StringContent(json), RequestUri = requestUri }; request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); request.Headers.Add("Authorization", "Basic " + authorizationValue); var result = await httpClient.SendAsync(request); result.EnsureSuccessStatusCode(); var content = await result.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <Core.Common.DTOs.ClientRegistrationResponse>(content)); }
public async Task <Core.Common.DTOs.ClientRegistrationResponse> ExecuteAsync(Core.Common.DTOs.Client client, Uri registrationUri) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (registrationUri == null) { throw new ArgumentNullException(nameof(registrationUri)); } return(await _registerClientOperation.ExecuteAsync(client, registrationUri, string.Empty)); }
public async Task <Core.Common.DTOs.ClientRegistrationResponse> ResolveAsync(Core.Common.DTOs.Client client, string configurationUrl) { if (string.IsNullOrWhiteSpace(configurationUrl)) { throw new ArgumentNullException(nameof(configurationUrl)); } Uri uri = null; if (!Uri.TryCreate(configurationUrl, UriKind.Absolute, out uri)) { throw new ArgumentException(string.Format(ErrorDescriptions.TheUrlIsNotWellFormed, configurationUrl)); } var discoveryDocument = await _getDiscoveryOperation.ExecuteAsync(uri); return(await ExecuteAsync(client, discoveryDocument.RegistrationEndPoint)); }
public async Task <Core.Common.DTOs.ClientRegistrationResponse> ExecuteAsync(Core.Common.DTOs.Client client, string registrationUrl) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (string.IsNullOrWhiteSpace(registrationUrl)) { throw new ArgumentNullException(nameof(registrationUrl)); } Uri uri = null; if (!Uri.TryCreate(registrationUrl, UriKind.Absolute, out uri)) { throw new ArgumentException(string.Format(ErrorDescriptions.TheUrlIsNotWellFormed, registrationUrl)); } return(await ExecuteAsync(client, uri)); }
public Core.Common.DTOs.ClientRegistrationResponse Execute(Core.Common.DTOs.Client client, string registrationUrl) { return(ExecuteAsync(client, registrationUrl).Result); }