我无法使用 aws.config.credentials.get() 方法获取访问密钥、密钥以及会话令牌。我拥有以上所有内容,例如身份验证和角色工作。
AWS.Config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: poolid,
'cognito-idp.us-east-1.amazonaws.com/us-east-1_aWAJIClAA' : result.getIdToken().getJwtToken()
});
console.log("Config.credentials "+ AWS.Config.credentials);
AWS.Config.credentials.get(function () {
console.log("credentials called ", AWS.Config.credentials);
// Credentials will be available when this function is called.
console.log("Access Key" + AWS.Config.credentials.accessKeyId );
console.log("Secret Key" + AWS.Config.credentials.secretAccessKey );
console.log("Session Token" + AWS.Config.credentials.sessionToken );
用户使用
session
登录后,您可以获得
user.getSession(callback)
变量
import AWS from 'aws-sdk';
const authenticator = `cognito-idp.${process.env.REACT_APP_AWS_REGION}.amazonaws.com/${process.env.REACT_APP_COGNITO_USER_POOL_ID}`
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId : process.env.IDENTITY_POOL_ID,
Logins : {
[authenticator]: session.getIdToken().getJwtToken()
}
});