AWS Cognito 错误:没有为未经身份验证的访问提供 Cognito 身份池

Car*_*arl 10 amazon-web-services amazon-cognito aws-amplify

var normalAuth = async (username, password) => {   
    try{
        var user = await Auth.signIn(username, password)
        console.log(user)
        if(user.challengeName === "NEW_PASSWORD_REQUIRED"){
            console.log("assigning new password!")
            user = await Auth.completeNewPassword(user, "password") // give the user a new password. this would NOT be included in any kind of production code, its only here as a work around
            console.log(user)
        } // work around. users created in the console are only given temporary passwords, and as such have no authorization
        // setting a new password will fix this

        console.log(await Auth.currentCredentials()) // THIS THROWS AN ERROR?!?!
        setAuthState(false) // auth is no longer in progress
    }
    catch(error){
        console.error(error)
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图在身份验证后从 Amplify 用户处获取令牌,但收到错误

No Cognito Identity pool provided for unauthenticated access
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为我根本没有使用身份池。我的基本假设是我根本不需要在放大配置中提供身份池 ID。

配置看起来像这样

var amplifyConfig = {
    Auth: {
        mandatorySignIn: false,
        region: "us-east-1",
        userPoolId: "mypoolid",
        userPoolWebClientId: "myclientid"
    }
}
Run Code Online (Sandbox Code Playgroud)

真正奇怪的部分是令牌实际上存在于user。只有当我尝试以这种方式检索它们时,才会抛出错误。

知道这是怎么回事吗?