首页 > 解决方案 > 无法通过 Nodejs 中的用户池返回的令牌访问身份池

问题描述

用户登录成功后,我正在尝试使用用户池返回的令牌访问身份池,但现在我得到:These credentials are not valid for accessing this resource。我已经在身份池的身份验证提供者中设置了 UserpoolId 和 ClientId。这是我的代码

    AWS.config.region = 'us-xxx-xx';
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: 'us-xxxxxx',
        Logins: {
            'cognito-idp.us-xxx-xx.amazonaws.com/us-xxx-xxx': 'token-return-from-user-pool'
        },
    });
    const cognito = new CognitoIdentity;
    const openIdToken = await cognito.getOpenIdTokenForDeveloperIdentity({
        IdentityPoolId: 'us-xxxxxx',
        Logins: {
            'cognito-idp.us-xxx-xx.amazonaws.com/us-xxx-xxx': 'token-return-from-user-pool'
        },
        TokenDuration: 3600,
    }).promise();

我收到此错误:These credentials are not valid for accessing this resource

我哪里错了?请帮我

标签: javascriptnode.jsamazon-web-servicesamazon-cognito

解决方案


推荐阅读