Example #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                CognitoHelper cognitoHelper = new CognitoHelper();
                cognitoUser = await cognitoHelper.ValidateUser(txtusername.Text, txtpassword.Text);

                MessageBox.Show("Login successfully");
                Console.WriteLine(cognitoUser.Username);

                CognitoAWSCredentials credentials = cognitoUser.GetCognitoAWSCredentials(ConfigurationManager.AppSettings["FED_POOL_id"], new AppConfigAWSRegion().Region);
                StringBuilder         tokens      = new StringBuilder();

                tokens.Append("================Cognito Credentails==================\n");
                tokens.Append("Access Key - " + credentials.GetCredentials().AccessKey);
                tokens.Append("\nSecret - " + credentials.GetCredentials().SecretKey);
                tokens.Append("\nSession Token - " + credentials.GetCredentials().Token);
                tokens.Append("\nUseToken Token - " + credentials.GetCredentials().UseToken.ToString());
                Console.WriteLine(tokens.ToString());
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp);
                MessageBox.Show("Unable to validate the username and password");
            }
        }
Example #2
0
        private async void Login_Click(object sender, RoutedEventArgs e)
        {
            CognitoHelper cognitoHelper = new CognitoHelper();

            ioioSetting.All.cognitoUser = await cognitoHelper.ValidateUser("atumm", "B@y7cgmc");

            Console.WriteLine(ioioSetting.All.cognitoUser.Username);
            string email = string.Empty;

            ioioSetting.All.cognitoUser.Attributes.TryGetValue("email", out email);
            GetUserResponse r = await cognitoHelper.GetUserInfo(ioioSetting.All.cognitoUser);

            Console.WriteLine(email);
        }
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                CognitoHelper cognitoHelper = new CognitoHelper();
                cognitoUser = await cognitoHelper.ValidateUser(txtusername.Text, txtpassword.Text);

                Console.WriteLine(cognitoUser.Username);
                string bucketsforuser = await cognitoHelper.GetS3BucketsAsync(cognitoUser);

                MessageBox.Show(bucketsforuser, "Buckets for the users");
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp);
                MessageBox.Show("Unable to validate the username and password");
            }
        }
Example #4
0
        private async void btnLogIn_Click(object sender, EventArgs e)
        {
            CognitoHelper cognitoHelper = new CognitoHelper();

            try
            {
                var cognitoUser = await cognitoHelper.ValidateUser(txtUsername.Text, txtPassword.Text);

                MessageBox.Show("Validated!");
            }
            catch (Amazon.CognitoIdentityProvider.Model.UserNotFoundException)
            {
                errorUI("User not found");
            }
            catch (Amazon.CognitoIdentityProvider.Model.InvalidPasswordException)
            {
                errorUI("Invalid password");
            }
            catch (Exception)
            {
                errorUI("Unexpected error");
            }
        }