public async Task <ActionResult <string> > Register(User user) { var cognito = new AmazonCognitoIdentityProviderClient(_region); var signUpRequest = new SignUpRequest { ClientId = _clientId, Password = user.Password, Username = user.Username }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; signUpRequest.UserAttributes.Add(emailAttribute); try { var response = await cognito.SignUpAsync(signUpRequest); return(Ok(response)); } catch (Exception ex) { return(Ok(ex)); } }
public async Task <Tuple <bool, string> > SignupUserAsync(string username, string email, string password) { try { SignUpRequest signUpRequest = new SignUpRequest() { ClientId = Constants.POOL_CLIENT_ID, Password = password, Username = username }; AttributeType emailAttribute = new AttributeType() { Name = "email", Value = email }; signUpRequest.UserAttributes.Add(emailAttribute); var signUpResult = await client.SignUpAsync(signUpRequest); if (signUpResult.HttpStatusCode == HttpStatusCode.OK) { return(Tuple.Create <bool, string>(true, "User Registered successfully!")); } } catch (Exception e) { return(Tuple.Create <bool, string>(false, e.Message)); } return(Tuple.Create <bool, string>(false, "Unable to register user!")); }
private async void btnSign_Click(object sender, RoutedEventArgs e) { try { SignUpRequest signUpRequest = new SignUpRequest() { ClientId = _clientId, Password = pW.Password, Username = txtEmail.Text }; AttributeType nameAttribute = new AttributeType() { Name = "given_name", Value = txtName.Text }; signUpRequest.UserAttributes.Add(nameAttribute); var signUpResult = await _client.SignUpAsync(signUpRequest); } catch (Exception ex) { string message = ex.Message; var msgBox = new MessageDialog(message, "Sign Up Error"); await msgBox.ShowAsync(); } }
private static async Task SignUpUser(string email, string password, string customerId) { IAmazonCognitoIdentityProvider provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), region); SignUpRequest signUpRequest = new SignUpRequest() { ClientId = appClientId, Username = email, Password = password }; List <AttributeType> attributes = new List <AttributeType>() { new AttributeType() { Name = "email", Value = email }, new AttributeType() { Name = "custom:stripeId", Value = customerId } }; signUpRequest.UserAttributes = attributes; try { SignUpResponse result = await provider.SignUpAsync(signUpRequest); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public override async Task <string> Handle(CognitoSignUpCommand request, CancellationToken cancellationToken) { using (var provider = new AmazonCognitoIdentityProviderClient(AwsId, AwsKey, RegionEndpoint.USEast1)) { var response = await provider.SignUpAsync(new SignUpRequest { Password = request.Password, ClientId = UserGroupClientId, Username = request.Email, UserAttributes = new List <AttributeType> { new AttributeType { Name = "email", Value = request.Email }, new AttributeType { Name = "preferred_username", Value = request.Username } } }, cancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new CognitoException("Failed to register user with email " + request.Email + "."); } return(response.UserSub); } }
public async Task <SignUpResponse> SignUpAsync(string email, string username, string password) { var client = new AmazonCognitoIdentityProviderClient(null, this.RegionEndpoint); SignUpRequest sr = new SignUpRequest(); sr.ClientId = this.ClientId; if (!string.IsNullOrEmpty(this.ClientSecret)) { sr.SecretHash = CalculateSecretHash(this.ClientId, this.ClientSecret, username); } sr.Username = username; sr.Password = password; sr.UserAttributes = new List <AttributeType> { new AttributeType { Name = "email", Value = email } }; try { SignUpResponse result = await client.SignUpAsync(sr); return(result); } catch (Exception ex) { throw; } }
public async Task <SignInResponse> SignIn(string username, string password) { try { var signUpRequest = new SignUpRequest { ClientId = Config.ClientId, Password = password, Username = username }; var emailAttribute = new AttributeType { Name = "email", Value = username }; signUpRequest.UserAttributes.Add(emailAttribute); var response = await _client.SignUpAsync(signUpRequest); return(new SignInResponse { UserId = response.UserSub }); } catch (Exception ex) { return(new SignInResponse { ErrorMessage = ex.Message }); } }
public async Task <IActionResult> Register(UserToCreateRequest userToCreateRequest) { var _client = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.USEast1); // Register the user using Cognito var signUpRequest = new SignUpRequest { ClientId = "4s8cbl7ptf75hp2tbqc14coib7", Password = "******", Username = "******", }; signUpRequest.UserAttributes.Add(new AttributeType { Name = "phone_number", Value = "+84765998291" }); signUpRequest.UserAttributes.Add(new AttributeType { Name = "name", Value = "NguyenKhanhDuy" }); var reponse = await _client.SignUpAsync(signUpRequest); return(Ok()); }
public Task CreateAsync(CognitoUser user) { // Register the user using Cognito var signUpRequest = new SignUpRequest { ClientId = ConfigurationManager.AppSettings["CLIENT_ID"], Password = user.Password, Username = user.Email, }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; signUpRequest.UserAttributes.Add(emailAttribute); _client.SignUpAsync(signUpRequest); _client.AdminConfirmSignUp(new AdminConfirmSignUpRequest { Username = user.Email, UserPoolId = _poolId }); return(Task.CompletedTask); }
private async void SignUpButton_Click(object sender, RoutedEventArgs e) { try { SignUpRequest signUpRequest = new SignUpRequest() { ClientId = _clientId, // SecretHash = "b33vuhrh0g1fq1jh7v4b4edv48vv0aua73tskf6fnsu7a4jq7cn", Password = PasswordTextBox.Password, Username = UserNameTextBox.Text }; /* * AttributeType emailAttribute = new AttributeType() * { * Name = "email", * Value = EmailTextBox.Text * }; * signUpRequest.UserAttributes.Add(emailAttribute); */ var signUpResult = await _client.SignUpAsync(signUpRequest); } catch (Exception ex) { string message = ex.Message; await new MessageDialog(message + "\n" + ex.ToString(), "Sign Up Error").ShowAsync(); } }
public async Task <CognitoContext> SignUp(string userName, string password) { try { var provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(), RegionEndpoint); var result = await provider.SignUpAsync(new SignUpRequest { ClientId = ClientId, Password = password, Username = userName }); Console.WriteLine("Signed in."); return(new CognitoContext(CognitoResult.SignupOk)); } catch (UsernameExistsException ue) { return(new CognitoContext(CognitoResult.UserNameAlreadyUsed)); } catch (InvalidParameterException ie) { return(new CognitoContext(CognitoResult.PasswordRequirementsFailed)); } catch (Exception e) { Console.WriteLine($"SignIn() threw an exception {e}"); } return(new CognitoContext(CognitoResult.Unknown)); }
public async Task SignupUser(string username, string password, string email) { try { UserInfo.Clear(); UserInfo.UserName = username; UserInfo.Email = email; AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.EUCentral1); SignUpRequest signUpRequest = new SignUpRequest(); signUpRequest.ClientId = CLIENTAPP_ID; signUpRequest.Username = username; signUpRequest.Password = password; AttributeType attributeType1 = new AttributeType(); attributeType1.Name = "email"; attributeType1.Value = email; signUpRequest.UserAttributes.Add(attributeType1); SignUpResponse signUpResponse = await provider.SignUpAsync(signUpRequest); UserInfo.Verified = signUpResponse.UserConfirmed; } catch (Exception ex) { Console.WriteLine("SignupUser ERROR: " + ex.Message); throw ex; } }
public async Task <CognitoContext> SignUp(string userName, string password) { try { SignUpResponse result = await awsProvider.SignUpAsync(new SignUpRequest { ClientId = Keys.AWS_UsersPool_ClientID, Password = password, Username = userName }); Debug.WriteLine($"From {this.GetType().Name}, Sign Up Succeeded"); return(new CognitoContext(CognitoResult.SignupOk)); //ProceedToCodeValidation(); } catch (UsernameExistsException) { Debug.WriteLine($"From {this.GetType().Name}, UsernameExistsException"); return(new CognitoContext(CognitoResult.UserNameAlreadyUsed)); } catch (InvalidPasswordException) { Debug.WriteLine($"From {this.GetType().Name}, InvalidPasswordException"); return(new CognitoContext(CognitoResult.PasswordRequirementsFailed)); } catch (Exception e) { //Sign Up failed, reason below Debug.WriteLine($"Exception in: {this.GetType().Name} error:{e.Message}"); return(new CognitoContext(CognitoResult.Unknown, e.Message)); } }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); User user = JsonConvert.DeserializeObject <User>(_postJson); var signUpRequest = new SignUpRequest { ClientId = ApiDefine.CognitoClientId, Password = user.Password, Username = user.Email }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; var nickNameAttribute = new AttributeType { Name = "nickname", Value = user.Name }; signUpRequest.UserAttributes.Add(emailAttribute); signUpRequest.UserAttributes.Add(nickNameAttribute); var client = new AmazonCognitoIdentityProviderClient(ApiDefine.Credentials, RegionEndpoint.USWest2); var result = await client.SignUpAsync(signUpRequest); JsPath = "cognito/sign.up.js"; string json = JsonConvert.SerializeObject(result); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
private async Task <SignUpResponse> TrySignUpUser(ISignupModelUser user) { try { SignUpRequest request = GetSignUpRequest(user); AmazonCognitoIdentityProviderClient client = GetAmazonCognitoIdentity(); SignUpResponse response = await client.SignUpAsync(request); return(response); } catch (UsernameExistsException e) { throw new WebApiException(System.Net.HttpStatusCode.Forbidden, e.Message); } catch (InvalidPasswordException e) { throw new WebApiException(System.Net.HttpStatusCode.BadRequest, e.Message); } catch (InvalidParameterException e) { throw new WebApiException(System.Net.HttpStatusCode.BadRequest, e.Message); } catch (Exception e) { throw new WebApiException(System.Net.HttpStatusCode.InternalServerError, e.Message); } }
public async Task <SignUpResponse> PerformSignUpAsync(UserForCreationDto user) { var signUpRequest = CreateSignUpRequestFromUserDto(user); AmazonCognitoIdentityProviderClient _client = new AmazonCognitoIdentityProviderClient(); var result = await _client.SignUpAsync(signUpRequest); return(result); }
public async Task <ActionResult <SignUpResponse> > Signup([FromBody] SignUpRequest request) { var signupClient = new AmazonCognitoIdentityProviderClient( new AnonymousAWSCredentials() ); var result = await signupClient.SignUpAsync(request).ConfigureAwait(false); this.logger.LogInformation("Successful cognito request"); return(new OkObjectResult(result)); }
public async Task <SignUpResponse> SignUp(User user) { var signUpRequest = new SignUpRequest { ClientId = cognitoAppClientId, Username = user.Email, Password = user.Password }; return(await _clientCognito.SignUpAsync(signUpRequest)); }
public async Task <SignUpResponse> SignUp(Guid userId, string password) { var signupRequest = new SignUpRequest { ClientId = clientId, Password = password, Username = userId.ToString() }; return(await cognitoIpClient.SignUpAsync(signupRequest)); }
public async Task <bool> SignUpUser() { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials()); SignUpRequest signUpRequest = new SignUpRequest { ClientId = ConfigurationManager.AppSettings["CLIENT_ID"], Username = emailInput.Value, Password = passwordInput.Value }; AttributeType emailAttr = new AttributeType { Name = "email", Value = emailInput.Value }; signUpRequest.UserAttributes.Add(emailAttr); AttributeType givenNameAttr = new AttributeType { Name = "given_name", Value = firstNameInput.Value }; signUpRequest.UserAttributes.Add(givenNameAttr); AttributeType familyNameAttr = new AttributeType { Name = "family_name", Value = lastNameInput.Value }; signUpRequest.UserAttributes.Add(familyNameAttr); try { SignUpResponse result = await provider.SignUpAsync(signUpRequest); return(true); } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", script, true); return(false); } }
public async Task <IAASUserRegisterResponse> Register(string userPoolClientId, string email, string password) { var request = new SignUpRequest { ClientId = userPoolClientId, Username = email, Password = password }; var response = await Client.SignUpAsync(request); return(new IAASUserRegisterResponse()); }
/// <summary> /// Use to Register User /// </summary> /// <param name="signUpRequest"></param> /// <returns></returns> public async Task <bool> UserSignUp(Real.UserSignUpRequest signUpRequest) { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials()); SignUpRequest request = new SignUpRequest(); request.Username = signUpRequest.username; request.Password = signUpRequest.password; request.UserAttributes.Add(new AttributeType { Name = "email", Value = signUpRequest.email }); request.UserAttributes.Add(new AttributeType { Name = "phone_number", Value = signUpRequest.number }); await provider.SignUpAsync(request); return(true); }
public async Task <ActionResult <string> > Register([FromBody] User user) { var cognito = new AmazonCognitoIdentityProviderClient(_region); var request = new SignUpRequest { ClientId = _clientId, Password = user.Password, Username = user.Username, UserAttributes = new List <AttributeType> { new AttributeType { Name = "family_name", Value = user.FamilyName }, new AttributeType { Name = "gender", Value = user.Gender }, new AttributeType { Name = "given_name", Value = user.GivenName }, new AttributeType { Name = "name", Value = user.Name }, new AttributeType { Name = "phone_number", Value = user.PhoneNumber }, new AttributeType { Name = "email", Value = user.Email } } }; try { await cognito.SignUpAsync(request); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public async Task <RequestResult> SignUpUser(User user) { RequestResult result = new RequestResult(); SignUpRequest signUpRequest = new SignUpRequest() { ClientId = CLIENTAPP_ID, Password = user.Password, Username = user.Email }; AttributeType attributeType = new AttributeType(); attributeType = new AttributeType(); attributeType.Name = "custom:firstname"; attributeType.Value = user.FirstName; signUpRequest.UserAttributes.Add(attributeType); attributeType = new AttributeType(); attributeType.Name = "custom:lastname"; attributeType.Value = user.LastName; signUpRequest.UserAttributes.Add(attributeType); attributeType = new AttributeType(); attributeType.Name = "custom:userid"; attributeType.Value = Guid.NewGuid().ToString(); signUpRequest.UserAttributes.Add(attributeType); try { SignUpResponse response = await provider.SignUpAsync(signUpRequest); result.Status = true; result.Message = "User Registerd Successfully!"; } catch (Exception e) { result.Status = false; result.Message = e.Message; } return(result); }
public Task CreateAsync(CognitoUser user) { // Register the user using Cognito var signUpRequest = new SignUpRequest { ClientId = _clientId, Password = user.Password, Username = user.Email, }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; signUpRequest.UserAttributes.Add(emailAttribute); return(_client.SignUpAsync(signUpRequest)); }
public async Task <ActionResult <string> > Register(User user) { var request = new SignUpRequest { ClientId = _clientId, Password = user.Password, Username = user.Username }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; request.UserAttributes.Add(emailAttribute); await _cognito.SignUpAsync(request); return(Ok()); }
public async Task <bool> Signup(string username, string email, string password) { // Debug.Log("SignUpRequest: " + username + ", " + email + ", " + password); SignUpRequest signUpRequest = new SignUpRequest() { ClientId = AppClientID, Username = email, Password = password }; // must provide all attributes required by the User Pool that you configured List <AttributeType> attributes = new List <AttributeType>() { new AttributeType() { Name = "email", Value = email }, new AttributeType() { Name = "preferred_username", Value = username } }; signUpRequest.UserAttributes = attributes; try { SignUpResponse sighupResponse = await _provider.SignUpAsync(signUpRequest); Debug.Log("Sign up successful"); return(true); } catch (Exception e) { Debug.Log("Sign up failed, exception: " + e); return(false); } }
public async Task <SignUpResponse> Register(AccountSignUpModel model) { var cognito = new AmazonCognitoIdentityProviderClient(_secret.AwsAccessKey, _secret.AwsSecretKey, _region); var request = new SignUpRequest { ClientId = _secret.ClientId, Password = model.Password, Username = model.Username }; var emailAttribute = new AttributeType { Name = "email", Value = model.Email }; request.UserAttributes.Add(emailAttribute); var response = await cognito.SignUpAsync(request); return(response); }
/// <summary> /// Create a new Cognito user. /// </summary> /// <returns></returns> public Task <SignUpResponse> CreateAsync(CognitoUser user) { var signUpRequest = new SignUpRequest { ClientId = _clientId, Password = user.Password, Username = user.Email, }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; signUpRequest.UserAttributes.Add(emailAttribute); using (var client = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), Amazon.RegionEndpoint.EUWest1)) { return(client.SignUpAsync(signUpRequest)); } }
//Method that creates a new Cognito user private async Task SignUpMethodAsync() { Debug.Log("Signup method called"); string userName = UsernameField.text; string password = PasswordField.text; string email = EmailField.text; AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), Region); SignUpRequest signUpRequest = new SignUpRequest() { ClientId = AppClientID, Username = userName, Password = password }; List <AttributeType> attributes = new List <AttributeType>() { new AttributeType() { Name = "email", Value = email } }; signUpRequest.UserAttributes = attributes; try { SignUpResponse request = await provider.SignUpAsync(signUpRequest); Debug.Log("Sign up worked"); } catch (Exception e) { Debug.Log("EXCEPTION" + e); return; } }