amazon-web-services – AWS Cognito无法在CognitoIdentityCredentials上设置凭据

我在为AWS Cognito设置凭据时遇到问题.

我使用案例4中的代码来自AWS amazon-cognito-identity-js.

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
            IdentityPoolId : '...', // your identity pool id here
            Logins : {
                // Change the key below according to the specific region your user pool is in.
                'cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>' : result.getIdToken().getJwtToken()
            }
        });

我已经检查过我在CognitoIdentityCredentials方法上发送了正确的IdentityPoolId和Logins,但是我在accessKeyId和sessionToken上未定义为返回.

以下是我得到的.
CognitoIdentityCredentials {expired:true,expireTime:null,accessKeyId:undefined,sessionToken:undefined,params:Object …}

知道如何解决这个问题吗?

最佳答案 在此之后,您调用’AWS.config.credentials.get()’以确保凭据提供程序请求凭据?

点赞