protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Application["AccessToken"] != null) { List <UserType> userList = new List <UserType>(); List <AttributeType> attributeList = new List <AttributeType>(); string accessKey = RDSContext.Create().awsCredentials.FirstOrDefault().AccessKey; string secretKey = RDSContext.Create().awsCredentials.FirstOrDefault().SecretKey; BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey); AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(basicAWSCredentials); if (HttpContext.Current.Application["AccessToken"] != null) { ListUsersRequest listUserRequest = new ListUsersRequest { UserPoolId = ConfigurationManager.AppSettings["USERPOOL_ID"], AttributesToGet = new List <string> { "email" }, }; ListUsersResponse response = provider.ListUsers(listUserRequest); userList.AddRange(response.Users); foreach (UserType u in userList) { attributeList.AddRange(u.Attributes); } GV1.DataSource = attributeList.Select(t => t.Value); GV1.DataBind(); GV1.HeaderRow.Cells[0].Text = "Email List"; } } }
public static List <UserType> GetAllUserPoolUsers() { var users = new List <UserType>(); var provider = new AmazonCognitoIdentityProviderClient(); string paginationToken = null; while (true) { var listUsersResponse = provider.ListUsers(new ListUsersRequest { UserPoolId = PoolId, PaginationToken = paginationToken }); paginationToken = listUsersResponse.PaginationToken; users.AddRange(listUsersResponse.Users); if (listUsersResponse.Users.Count == 0 || string.IsNullOrEmpty(paginationToken)) { break; } } return(users); }