gpt4 book ai didi

java - 如何在 Cognito 中使用 adminGetUserRequest 获取用户属性

转载 作者:行者123 更新时间:2023-12-04 17:25:04 27 4
gpt4 key购买 nike

我正在尝试使用 AdminGetUserRequest 从 cognito 获取用户属性,以下是我的代码:

public class getUserDetails {
public static void main(String[] args) {
String app_client_id ="xxxxxxxxxxxx";
String app_client_secret ="xxxxxxxxxxx";
String user_pool_id ="xxxxxxxxx";
String region = "xxxxxxxxxx";
String AWS_ACCESS_KEY = "xxxxxxxxxx";
String AWS_SECRET_KEY = "xxxxxxxxxx";
AWSCredentials awsCreds = new BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY);
AWSCognitoIdentityProvider client = AWSCognitoIdentityProviderClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withRegion(region)
.build();
AdminGetUserRequest adminGetUserRequest = new AdminGetUserRequest()
.withUserPoolId(user_pool_id)
.withUsername("testUser");

try {
AdminGetUserResult adminGetUserResult = client.adminGetUser(adminGetUserRequest);
System.out.println(adminGetUserResult.getUserAttributes());
}catch (UserNotFoundException e) {
System.out.println("User not found");
}
}
}

代码运行良好,我正在获取用户,但属性值列为Sensitive Data Redacted。我得到的输出如下

[{Name: sub,Value: ***Sensitive Data Redacted***}, {Name: email_verified,Value: ***Sensitive Data Redacted***}, {Name: email,Value: ***Sensitive Data Redacted***}]

如何获取列为Sensitive Data Redacted 的值。我没有任何访问 token ,我只有用于检索这些值的用户名。

最佳答案

我相信这只是 https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/cognitoidp/model/AttributeType.htmltoString 方法的默认实现防止意外记录敏感数据。

尝试明确请求 getValue,我相信你会得到你的值(value)。

关于java - 如何在 Cognito 中使用 adminGetUserRequest 获取用户属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63937756/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com