AWS Cognito无法在CognitoIdentityCredentials上设置凭证

Ohs*_*sik 6 amazon-web-services aws-sdk aws-cognito

我在设置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()
            }
        });
Run Code Online (Sandbox Code Playgroud)

我检查了,我传送给正确的IdentityPoolIdLoginsCognitoIdentityCredentials的方法,但我得到了一个未定义的accessKeyId和sessionToken作为回报。

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

任何想法如何解决这个问题?

Rob*_*eux 1

之后,您是否调用“AWS.config.credentials.get()”以确保凭证提供程序请求凭证?