// These are just thin wrappers over the SDK to show how to use them: // Call once, or when the carrier changes. May throw DistributedMatchEngine.HttpException. public async Task <bool> Register() { // If MEX is reachable on your SIM card: string aCarrierName = GetCarrierName(); string eCarrierName; if (me.useOnlyWifi) { eCarrierName = carrierName; } else { if (aCarrierName == null) { Debug.Log("Missing CarrierName for RegisterClient."); return(false); } eCarrierName = aCarrierName; } RegisterClientRequest req = me.CreateRegisterClientRequest(eCarrierName, orgName, appName, appVers, authToken, cellID, uniqueIDType, uniqueID, tags); Debug.Log("CarrierName: " + req.carrier_name); Debug.Log("orgName: " + req.org_name); Debug.Log("AppName: " + req.app_name); Debug.Log("AppVers: " + req.app_vers); RegisterClientReply reply = await me.RegisterClient(req); return(reply.status == ReplyStatus.RS_SUCCESS); }
public void RegisterClientTest() { //Arrange var dbLayer = new Mock <IDbAdvertApiService>(); var newRegisterClientRequest = new RegisterClientRequest { FirstName = "Tomek", LastName = "Palczewski", Email = "*****@*****.**", Phone = "666999666", Login = "******", Password = "******" }; var newClient = new Client { FirstName = "Tomek", LastName = "Palczewski", Email = "*****@*****.**", Phone = "666999666", Login = "******", Password = "******" }; dbLayer.Setup(m => m.RegisterClient(newRegisterClientRequest)).Returns(newClient); var cont = new ClientController(dbLayer.Object); //Act var result = cont.RegisterClient(newRegisterClientRequest); //Assert Assert.IsNotNull(result); }
public async Task <int> RegisterClient(RegisterClientRequest request) { Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = _db.Database.BeginTransaction(); ClientEntity client = new ClientEntity { FirstName = request.FirstName, LastName = request.LastName, SexId = (byte)request.Sex, PersonalNumber = request.PersonalNumber, BirthDate = request.BirthDate, BirthCity = request.City, //PhotoUrl = request.PhotoAddress, StatusId = 1 }; await _db.Client.SingleInsertAsync(client); await _db.ClientPhoneNumber.BulkInsertAsync(request.PhoneNumbers.Select(x => new ClientPhoneNumberEntity { ClientId = client.Id, TypeId = (byte)x.Type, Phone = x.Phone })); //await _db.ClientRelation.BulkInsertAsync(request.RelatedClients.Select(x => new ClientRelation { ClientId = client.Id, TypeId = (byte)x.Type, RelativeId = x.Id })); await transaction.CommitAsync(); return(client.Id); }
public static GetSsoTokenResponse GetSsoToken(IAmazonSSOOIDC client, GetSsoTokenRequest request, IGetSsoTokenContext context) { var registerClientRequest = new RegisterClientRequest() { ClientName = request.ClientName, ClientType = request.ClientType, }; InternalSDKUtils.ApplyValues(registerClientRequest, request.AdditionalProperties); var registerClientResponse = client.RegisterClient(registerClientRequest); var startDeviceAuthorizationRequest = new StartDeviceAuthorizationRequest() { ClientSecret = registerClientResponse.ClientSecret, ClientId = registerClientResponse.ClientId, StartUrl = request.StartUrl, }; InternalSDKUtils.ApplyValues(startDeviceAuthorizationRequest, request.AdditionalProperties); var startDeviceAuthorizationResponse = client.StartDeviceAuthorization(startDeviceAuthorizationRequest); // Spec: The expiration time must be calculated by adding the number of seconds // returned by StartDeviceAuthorization (ExpiresIn) to the current time. DateTime deviceCodeExpiration = DateTime.UtcNow.AddSeconds(startDeviceAuthorizationResponse.ExpiresIn); request.SsoVerificationCallback(new SsoVerificationArguments() { UserCode = startDeviceAuthorizationResponse.UserCode, VerificationUri = startDeviceAuthorizationResponse.VerificationUri, VerificationUriComplete = startDeviceAuthorizationResponse.VerificationUriComplete, }); var createTokenRequest = new CreateTokenRequest() { ClientId = registerClientResponse.ClientId, ClientSecret = registerClientResponse.ClientSecret, GrantType = CreateTokenGrantType, DeviceCode = startDeviceAuthorizationResponse.DeviceCode, }; InternalSDKUtils.ApplyValues(request, request.AdditionalProperties); var ssoToken = PollForSsoToken(client, createTokenRequest, startDeviceAuthorizationResponse.Interval, deviceCodeExpiration, context); return(new GetSsoTokenResponse() { AccessToken = ssoToken.AccessToken, ExpiresAt = DateTime.UtcNow.AddSeconds(ssoToken.ExpiresIn), }); }
/// <summary> /// Registers a client with AWS SSO. This allows clients to initiate device authorization. /// The output should be persisted for reuse through many authentication requests. /// </summary> /// <param name="request">Container for the necessary parameters to execute the RegisterClient service method.</param> /// /// <returns>The response from the RegisterClient service method, as returned by SSOOIDC.</returns> /// <exception cref="Amazon.SSOOIDC.Model.InternalServerException"> /// Indicates that an error from the service occurred while trying to process a request. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidClientMetadataException"> /// Indicates that the client information sent in the request during registration is invalid. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidRequestException"> /// Indicates that something is wrong with the input to the request. For example, a required /// parameter might be missing or out of range. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidScopeException"> /// Indicates that the scope provided in the request is invalid. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-oidc-2019-06-10/RegisterClient">REST API Reference for RegisterClient Operation</seealso> public virtual RegisterClientResponse RegisterClient(RegisterClientRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = RegisterClientRequestMarshaller.Instance; options.ResponseUnmarshaller = RegisterClientResponseUnmarshaller.Instance; return(Invoke <RegisterClientResponse>(request, options)); }
/// <summary> /// Registers a client with AWS SSO. This allows clients to initiate device authorization. /// The output should be persisted for reuse through many authentication requests. /// </summary> /// <param name="request">Container for the necessary parameters to execute the RegisterClient service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the RegisterClient service method, as returned by SSOOIDC.</returns> /// <exception cref="Amazon.SSOOIDC.Model.InternalServerException"> /// Indicates that an error from the service occurred while trying to process a request. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidClientMetadataException"> /// Indicates that the client information sent in the request during registration is invalid. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidRequestException"> /// Indicates that something is wrong with the input to the request. For example, a required /// parameter might be missing or out of range. /// </exception> /// <exception cref="Amazon.SSOOIDC.Model.InvalidScopeException"> /// Indicates that the scope provided in the request is invalid. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-oidc-2019-06-10/RegisterClient">REST API Reference for RegisterClient Operation</seealso> public virtual Task <RegisterClientResponse> RegisterClientAsync(RegisterClientRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = RegisterClientRequestMarshaller.Instance; options.ResponseUnmarshaller = RegisterClientResponseUnmarshaller.Instance; return(InvokeAsync <RegisterClientResponse>(request, options, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the RegisterClient operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the RegisterClient operation on AmazonSSOOIDCClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndRegisterClient /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-oidc-2019-06-10/RegisterClient">REST API Reference for RegisterClient Operation</seealso> public virtual IAsyncResult BeginRegisterClient(RegisterClientRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = RegisterClientRequestMarshaller.Instance; options.ResponseUnmarshaller = RegisterClientResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task RegisterClient(RegisterClientRequest request) { await Policy .Handle <WebException>() .WaitAndRetryAsync ( retryCount: 5, sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)) ) .ExecuteAsync(async() => await PottiRomaApiAccess.GetPottiRomaApi <IClientsRefit>().RegisterClient(request) ); }
public IActionResult RegisterClient(RegisterClientRequest request) { try { var result = _context.RegisterClient(request); return(Ok(result)); } catch (ClientIsAlreadyInDatabaseException exc) { return(BadRequest(exc.Message)); } catch (UserWithThisLoginAlreadyExistsException exc) { return(BadRequest(exc.Message)); } }
public async Task <object> RegisterClient(RegisterClientRequest client) { var response = await _httpClient.PostAsync("applications", new StringContent(JsonSerializer.Serialize(client, new JsonSerializerOptions() { IgnoreNullValues = true }), Encoding.UTF8, "application/json")); var stringResponse = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { return(JsonSerializer.Deserialize <SsoError>(stringResponse, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true })); } return(JsonSerializer.Deserialize <RegisterClientResponse>(stringResponse, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true })); }
// These are just thin wrappers over the SDK to show how to use them: // Call once, or when the carrier changes. May throw DistributedMatchEngine.HttpException. public async Task <bool> Register() { // If MEX is reachable on your SIM card: string aCarrierName = GetCarrierName(); string eCarrierName; if (useDemo) { eCarrierName = carrierName; } else { if (aCarrierName == null) { Debug.Log("Missing CarrierName for RegisterClient."); return(false); } eCarrierName = aCarrierName; } RegisterClientRequest req = me.CreateRegisterClientRequest(eCarrierName, devName, appName, appVers, "" /* developer specific string blob */); Debug.Log("CarrierName: " + req.carrier_name); Debug.Log("DevName: " + req.dev_name); Debug.Log("AppName: " + req.app_name); Debug.Log("AppVers: " + req.app_vers); RegisterClientReply reply; if (useDemo) { reply = await me.RegisterClient(dmeHost, dmePort, req); } else { reply = await me.RegisterClient(req); } return(reply.status == ReplyStatus.RS_SUCCESS); }
public Client RegisterClient(RegisterClientRequest request) { var isClientInDatabase = _context.Clients.Where (m => m.FirstName == request.FirstName && m.LastName == request.LastName && m.Phone == request.Phone && m.Email == request.Email).FirstOrDefault(); if (isClientInDatabase != null) { throw new ClientIsAlreadyInDatabaseException("Client is already in databse"); } var isLoginInUse = _context.Clients.Count(m => m.Login == request.Login); if (isLoginInUse != 0) { throw new UserWithThisLoginAlreadyExistsException("Login is already use by another user, please change login name"); } string salt = CreateSalt(); string hashPassword = Create(request.Password, salt); var client = new Client { FirstName = request.FirstName, LastName = request.LastName, Email = request.Email, Phone = request.Phone, Login = request.Login, Password = hashPassword, Salt = salt }; _context.Attach(client); _context.Add(client); _context.SaveChangesAsync(); return(client); }
public void AssertRegisterClientAsyncRequest(RegisterClientRequest expectedRequest) { OidcClient.Verify( mock => mock.RegisterClientAsync(It.Is <RegisterClientRequest>(MatchesRequest(expectedRequest)), It.IsAny <CancellationToken>()), Times.Once); }
private static Expression <Func <RegisterClientRequest, bool> > MatchesRequest( RegisterClientRequest expectedRequest) { return(request => request.ClientName == expectedRequest.ClientName && request.ClientType == expectedRequest.ClientType); }
public override void RegisterClient(IRpcController controller, RegisterClientRequest request, Action<NoData> done) { throw new NotImplementedException(); }
/// Call once, or when the carrier changes. May throw DistributedMatchEngine.HttpException. /// <summary> /// Wrapper for Register Client. First call to establish the connection with your backend(server) deployed on MobiledgeX /// </summary> /// <returns>bool Task</returns> public async Task <bool> Register(string dmeHost = null, uint dmePort = 0) { latestRegisterStatus = false; RegisterClientRequest req = matchingEngine.CreateRegisterClientRequest(orgName, appName, appVers, developerAuthToken.Length > 0 ? developerAuthToken : null); Logger.Log("OrgName: " + req.org_name); Logger.Log("AppName: " + req.app_name); Logger.Log("AppVers: " + req.app_vers); try { await UpdateLocationAndCarrierInfo(); } catch (CarrierInfoException cie) { Debug.LogError("MobiledgeX: Register Exception: " + cie.Message); throw new RegisterClientException(cie.Message); } RegisterClientReply reply = null; try { if (dmeHost != null && dmePort != 0) { Logger.Log("Doing Register Client with DME: " + dmeHost + ", p: " + dmePort + " with req: " + req); reply = await matchingEngine.RegisterClient(dmeHost, dmePort, req); } else { if (!useSelectedRegionInProduction) { #if UNITY_EDITOR Logger.Log("Doing Register Client with DME: " + region + ", p: " + MatchingEngine.defaultDmeRestPort + " with req: " + req); Logger.LogWarning("Region Selection will work only in UnityEditor not on Mobile Devices"); reply = await matchingEngine.RegisterClient(region, MatchingEngine.defaultDmeRestPort, req); #else Logger.Log("Doing Register Client, with req: " + req); reply = await matchingEngine.RegisterClient(req); #endif } else { Logger.Log("MobiledgeX: Doing Register Client with DME: " + region + ", p: " + MatchingEngine.defaultDmeRestPort + " with req: " + req); reply = await matchingEngine.RegisterClient(region, MatchingEngine.defaultDmeRestPort, req); } } } catch (HttpException httpe) { Debug.LogError("MobiledgeX: RegisterClient HttpException: " + httpe.Message); throw new RegisterClientException("RegisterClient Exception: " + httpe.Message + ", HTTP StatusCode: " + httpe.HttpStatusCode + ", API ErrorCode: " + httpe.ErrorCode + "\nStack: " + httpe.StackTrace); } catch (Exception e) { throw new RegisterClientException("MobiledgeX: RegisterClient Exception Type: " + e.GetType() + ", Message: " + e.Message + ", InnerException : " + e.InnerException + "\nStack: " + e.StackTrace); } finally { if (reply == null) { Debug.LogError("MobiledgeX: Register reply NULL!"); throw new RegisterClientException("RegisterClient returned null."); } if (reply.status != ReplyStatus.RS_SUCCESS) { Debug.LogError("MobiledgeX: Register Failed: " + reply.status); throw new RegisterClientException("Bad RegisterClient. RegisterClient status is " + reply.status); } } latestRegisterStatus = true; return(true); }
public override void RegisterClient(IRpcController controller, RegisterClientRequest request, Action <NoData> done) { throw new NotImplementedException(); }
public override void RegisterClient(Google.ProtocolBuffers.IRpcController controller, RegisterClientRequest request, Action<bnet.protocol.NoData> done) { throw new NotImplementedException(); }
public static async Task <OAuth2Client> RegisterClientAsync(Uri clientRegistrationEndpoint, string initialAccessToken, string softwareId, string softwareVersion, OAuth2TokenEndpointAuthMethod tokenEndpointAuthMethod, List <OAuth2GrantType> grantTypes, List <string> redirectUris, List <string> scopes) { /* STEP 1: validate all arguments */ // validate our clientRegistrationEndpoint uri if (clientRegistrationEndpoint == null) { throw new ArgumentNullException(nameof(clientRegistrationEndpoint)); } else if (clientRegistrationEndpoint.Scheme.ToLowerInvariant() != "https") { throw new ArgumentException("clientRegistrationEndpoint must be secured with the https protocol.", nameof(clientRegistrationEndpoint)); } /* validate redirectUris: make sure that the redirectUris use HTTPS or a non-HTTP protocol (e.g. an app-specific protocol on a mobile * device). HTTP is also valid with redirectUris--but only for the localhost. */ if (redirectUris != null) { for (int iRedirectUri = 0; iRedirectUri < redirectUris.Count; iRedirectUri++) { // break the redirectUri down into its components (scheme, host, etc.) Uri uri; try { uri = new Uri(redirectUris[iRedirectUri]); } catch { throw new ArgumentException("redirectUris[" + iRedirectUri + "] is a malformed redirect uri.", nameof(redirectUris)); } // if (uri.Host == null) { throw new ArgumentException("redirectUris[" + iRedirectUri + "] is a malformed redirect uri.", nameof(redirectUris)); } // switch (uri.Scheme.ToLowerInvariant()) { case "http": // HTTP scheme is okay as long as the server is localhost (i.e. communication is on the loopback interface). if (uri.Host != "127.0.0.1" && uri.Host != "::1" && uri.Host.ToLowerInvariant() != "localhost") { throw new ArgumentException("redirectUris[" + iRedirectUri + "] must be secured with the https protocol.", nameof(redirectUris)); } break; case "https": // HTTPS scheme is okay break; default: // custom app-specific schemes are okay break; } } } // validate our scopes: they cannot contain any spaces and they must conform to our "allowable characters" rules. if (scopes != null) { for (int iScope = 0; iScope < scopes.Count; iScope++) { if (ContainsOnlyAllowedScopeCharacters(scopes[iScope]) == false) { throw new ArgumentException("scopes[" + iScope + "] may only contain letters, numbers and the following characters: '" + string.Join("', '", _allowedScopeSpecialCharactersAsString.ToArray()) + "'", nameof(scopes)); } } } // validate the grantTypes /* Supported grantType options (including combinations) are: * .AuthorizationCode * .AuthorizationCode, .RefreshToken * .Implicit * .Password * .Password, .RefreshToken * .ClientCredentials */ OAuth2GrantType grantType; bool requestRefreshTokenGrantType = false; if (grantTypes == null || grantTypes.Count == 0) { // if no grant type was provided, use the default grantType = OAuth2GrantType.AuthorizationCode; } else if (grantTypes.Count == 1 && grantTypes.Contains(OAuth2GrantType.AuthorizationCode)) { grantType = OAuth2GrantType.AuthorizationCode; } else if (grantTypes.Count == 2 && grantTypes.Contains(OAuth2GrantType.AuthorizationCode) && grantTypes.Contains(OAuth2GrantType.RefreshToken)) { grantType = OAuth2GrantType.AuthorizationCode; requestRefreshTokenGrantType = true; } else if (grantTypes.Count == 1 && grantTypes.Contains(OAuth2GrantType.Implicit)) { grantType = OAuth2GrantType.Implicit; } else if (grantTypes.Count == 1 && grantTypes.Contains(OAuth2GrantType.Password)) { grantType = OAuth2GrantType.Password; } else if (grantTypes.Count == 2 && grantTypes.Contains(OAuth2GrantType.Password) && grantTypes.Contains(OAuth2GrantType.RefreshToken)) { grantType = OAuth2GrantType.Password; requestRefreshTokenGrantType = true; } else if (grantTypes.Count == 1 && grantTypes.Contains(OAuth2GrantType.ClientCredentials)) { grantType = OAuth2GrantType.ClientCredentials; } else { throw new ArgumentException("grantTypes contains an " + (grantTypes.Count > 1 ? "invalid combination of grant types" : "invalid grant type") + ".", nameof(grantTypes)); } // validate the grantType and tokenEndpointAuthMethod (and assign the corresponding responseType) OAuth2ResponseType?responseType = null; switch (grantType) { case OAuth2GrantType.AuthorizationCode: responseType = OAuth2ResponseType.Code; if (tokenEndpointAuthMethod != OAuth2TokenEndpointAuthMethod.ClientSecretBasic && tokenEndpointAuthMethod != OAuth2TokenEndpointAuthMethod.None) { throw new ArgumentException("A grantType does not support the requested tokenEndpointAuthMethod.", nameof(grantType)); } break; case OAuth2GrantType.Implicit: responseType = OAuth2ResponseType.Token; if (tokenEndpointAuthMethod != OAuth2TokenEndpointAuthMethod.None) { throw new ArgumentException("A grantType does not support the requested tokenEndpointAuthMethod.", nameof(grantType)); } break; case OAuth2GrantType.ClientCredentials: responseType = null; if (tokenEndpointAuthMethod != OAuth2TokenEndpointAuthMethod.ClientSecretBasic) { throw new ArgumentException("A grantType does not support the requested tokenEndpointAuthMethod.", nameof(grantType)); } break; case OAuth2GrantType.Password: responseType = null; if (tokenEndpointAuthMethod != OAuth2TokenEndpointAuthMethod.ClientSecretBasic) { throw new ArgumentException("A grantType does not support the requested tokenEndpointAuthMethod.", nameof(grantType)); } break; } // verify that, if grant types require redirect uris, our caller has included at least one redirectUri. switch (grantType) { case OAuth2GrantType.AuthorizationCode: case OAuth2GrantType.Implicit: if (redirectUris == null || redirectUris.Count == 0) { throw new ArgumentException(grantType.ToString() + " requires redirectUris.", nameof(redirectUris)); } break; default: // no response URIs required. break; } /* STEP 2: create our JSON request payload */ RegisterClientRequest requestPayload = new RegisterClientRequest(); requestPayload.software_id = softwareId; requestPayload.software_version = softwareVersion; if (redirectUris != null) { requestPayload.redirect_uris = redirectUris.ToArray(); } // token endpoint auth method requestPayload.token_endpoint_auth_method = OAuth2Convert.ConvertTokenEndpointAuthMethodToString(tokenEndpointAuthMethod); // grant types if (requestRefreshTokenGrantType) { requestPayload.grant_types = new string[] { OAuth2Convert.ConvertGrantTypeToString(grantType), OAuth2Convert.ConvertGrantTypeToString(OAuth2GrantType.RefreshToken) }; } else { requestPayload.grant_types = new string[] { OAuth2Convert.ConvertGrantTypeToString(grantType) }; } // response types if (responseType != null) { requestPayload.response_types = new string[] { OAuth2Convert.ConvertResponseTypeToString(responseType.Value) }; } // scopes if (scopes != null) { requestPayload.scope = String.Join(" ", scopes.ToArray()); } // string jsonEncodedRequestPayload = JsonConvert.SerializeObject(requestPayload, Formatting.None, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); /* STEP 3: send our dynamic client registration request */ try { using (HttpClient httpClient = new HttpClient()) { // create request var requestMessage = new HttpRequestMessage(HttpMethod.Post, clientRegistrationEndpoint); requestMessage.Content = new HttpStringContent(jsonEncodedRequestPayload, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"); requestMessage.Headers.Accept.Clear(); requestMessage.Headers.Accept.Add(new Windows.Web.Http.Headers.HttpMediaTypeWithQualityHeaderValue("application/json")); if (initialAccessToken != null) { requestMessage.Headers.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Bearer", initialAccessToken); } // send request HttpResponseMessage responseMessage = await httpClient.SendRequestAsync(requestMessage); // process response switch (responseMessage.StatusCode) { case HttpStatusCode.Created: { // client was registered; parse response RegisterClientResponse responsePayload = JsonConvert.DeserializeObject <RegisterClientResponse>(await responseMessage.Content.ReadAsStringAsync()); if (responsePayload.client_id == null) { throw new OAuth2ServerErrorException(); } OAuth2Client client = new OAuth2Client(); // Id client.Id = responsePayload.client_id; // Secret client.Secret = responsePayload.client_secret; // IssuedAt if (responsePayload.client_id_issued_at != null) { client.IssuedAt = DateTimeOffset.FromUnixTimeSeconds(long.Parse(responsePayload.client_id_issued_at.Value.ToString())); } // ExpiresAt if (responsePayload.client_secret_expires_at != null && responsePayload.client_secret_expires_at != 0) { client.SecretExpiresAt = DateTimeOffset.FromUnixTimeSeconds(long.Parse(responsePayload.client_secret_expires_at.Value.ToString())); } // SoftwareId client.SoftwareId = responsePayload.software_id; // SoftwareVersion client.SoftwareVersion = responsePayload.software_version; // RedirectUris if (responsePayload.redirect_uris != null) { client.RedirectUris = responsePayload.redirect_uris.ToList <string>(); } // TokenEndpointAuthMethod if (responsePayload.token_endpoint_auth_method != null) { OAuth2TokenEndpointAuthMethod?allowedTokenEndpointAuthMethod = OAuth2Convert.ConvertStringToTokenEndpointAuthMethod(responsePayload.token_endpoint_auth_method); if (allowedTokenEndpointAuthMethod != null) { client.TokenEndpointAuthMethod = allowedTokenEndpointAuthMethod.Value; } } // GrantTypes if (responsePayload.grant_types != null) { client.GrantTypes = new List <OAuth2.OAuth2GrantType>(); foreach (string grantTypeAsString in responsePayload.grant_types) { OAuth2GrantType?allowedGrantType = OAuth2Convert.ConvertStringToGrantType(grantTypeAsString); if (allowedGrantType != null) { client.GrantTypes.Add(allowedGrantType.Value); } } } // Scope client.Scope = responsePayload.scope; // RegistrationAccessToken and RegistrationAccessUri if (responsePayload.registration_access_token != null && responsePayload.registration_client_uri != null) { // RegistrationAccessToken client.RegistrationToken = responsePayload.registration_access_token; // RegistrationAccessUri client.RegistrationUri = responsePayload.registration_client_uri; } // return our client return(client); } case HttpStatusCode.BadRequest: { // process the "bad request" response OAuth2ErrorResponse responsePayload = JsonConvert.DeserializeObject <OAuth2ErrorResponse>(await responseMessage.Content.ReadAsStringAsync()); if (responsePayload.error == null) { throw new OAuth2ServerErrorException(); } switch (responsePayload.error.ToLowerInvariant()) { case "invalid_redirect_uri": throw new ArgumentException(responsePayload.error_description ?? responsePayload.error, nameof(redirectUris)); case "invalid_client_metadata": throw new ArgumentException(responsePayload.error_description ?? responsePayload.error); default: throw new OAuth2HttpException(responseMessage.StatusCode); } } case HttpStatusCode.PaymentRequired: throw new OAuth2PaymentRequiredException(); case HttpStatusCode.Forbidden: throw new OAuth2ForbiddenException(); case HttpStatusCode.TooManyRequests: throw new OAuth2TooManyRequestsException(); case HttpStatusCode.InternalServerError: throw new OAuth2ServerErrorException(); case HttpStatusCode.ServiceUnavailable: throw new OAuth2ServiceUnavailableException(); default: throw new OAuth2HttpException(responseMessage.StatusCode); } } } catch (JsonException) { // JSON parsing error; this is catastrophic. throw new OAuth2ServerErrorException(); } catch { // NOTE: callers must catch non-HTTP networking exceptions throw; } }
public async Task <int> RegisterClient(RegisterClientRequest request) { return(await _repository.RegisterClient(request)); }
public async Task RegisterClient(RegisterClientRequest request) { await ClientsApiRepository.Get().RegisterClient(request); }
public async Task <IActionResult> RegisterClient([FromBody] RegisterClientRequest request) { int id = await _clientService.RegisterClient(request); return(Ok(new PutClientResponse(id))); }
public void AssertRegisterClientRequest(RegisterClientRequest expectedRequest) { OidcClient.Verify(mock => mock.RegisterClient(It.Is <RegisterClientRequest>(MatchesRequest(expectedRequest))), Times.Once); }
public override void RegisterClient(IRpcController controller, RegisterClientRequest request, Action<NoData> done) { ProtoOutputBuffer.Write(request.GetType(), request.ToString()); }
public override void RegisterClient(IRpcController controller, RegisterClientRequest request, Action <NoData> done) { ProtoOutputBuffer.Write(request.GetType(), request.ToString()); }
public async Task RegisterClient(RegisterClientRequest request) { //await ValidateToken(); _clientsService.RegisterClient(request.UsuarioId, request.Name, request.Telephone, request.Email, request.Cep, request.Birthdate); }
public override void RegisterClient(Google.ProtocolBuffers.IRpcController controller, RegisterClientRequest request, Action <bnet.protocol.NoData> done) { throw new NotImplementedException(); }