【发布时间】:2019-02-28 11:45:30
【问题描述】:
我在 aws cognito 中有一个用户池,其中包含大约 100 个用户详细信息。我想通过 java 代码列出所有用户的电子邮件。下面是代码-
AWSCognitoIdentityProvider cognitoIdentityProvider = AWSCognitoIdentityProviderClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withRegion(Regions.fromName(REGION))
.build();
try {
ListUsersRequest req=new ListUsersRequest();
req=req.withUserPoolId(POOL_ID);
List<String> attributesToGet=new ArrayList<>();
attributesToGet.add("email");
ListUsersResult response = cognitoIdentityProvider.listUsers(req);
System.out.println(response.getUsers());
但是当我运行代码时,我得到异常 -com.amazonaws.services.cognitoidp.model.AWSCognitoIdentityProviderException:缺少身份验证令牌(服务:AWSCognitoIdentityProvider;状态代码:400;错误代码:MissingAuthenticationTokenException。强> 如何解决这个问题或者有没有其他方法可以打印所有用户?
【问题讨论】:
标签: amazon-web-services aws-sdk amazon-cognito