【发布时间】:2019-12-27 21:53:59
【问题描述】:
我有一个 Java 后端服务,我想使用 AWS Cognito 提供对 AWS 服务的身份验证和访问。该服务没有关于 AWS 账户的任何信息。我看到所有客户端都需要 AWS 凭证或管理员凭证才能创建它们。如何在不了解 AWS 账户的情况下仅使用用户池中的用户来授予对这项服务的访问权限?
我已经尝试过客户端和服务器端,但它们都需要 aws 凭据来创建用户池和身份池客户端,然后才能获取访问令牌。
try {
credentials = new ProfileCredentialsProvider("default").getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (/Users/ayushaws/.aws/credentials), and is in valid format.",
e);
}
// Creating Cognito user pool client
AWSCognitoIdentityProvider client = AWSCognitoIdentityProviderClientBuilder.standard()
.withRegion("us-east-1")
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
这就是我目前创建客户的方式。我的问题是,这最初需要我的凭据来创建客户端。如果使用的应用程序在 AWS 之外并且不知道 AWS 帐户,我们如何创建客户端。
【问题讨论】:
标签: amazon-web-services amazon-cognito