amazon-web-services - AWS Cognito 错误:没有为未经身份验证的访问提供 Cognito 身份池
问题描述
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)
}
}
我正在尝试在身份验证后从我的 Amplify 用户那里获取令牌,但我收到了错误
No Cognito Identity pool provided for unauthenticated access
这很奇怪,因为我根本没有使用身份池。我的基线假设是我根本不需要在我的放大配置中提供身份池 ID。
配置看起来像这样
var amplifyConfig = {
Auth: {
mandatorySignIn: false,
region: "us-east-1",
userPoolId: "mypoolid",
userPoolWebClientId: "myclientid"
}
}
user
真正奇怪的部分是,在我进行身份验证后,令牌实际上就在那里。只有当我尝试以这种方式特别检索它们时才会引发错误。
知道这里发生了什么吗?
解决方案
推荐阅读
- javascript - How to write a SignalR javascript code on asp.net mvc, when we instantiate the hub on Application_Start
- logback - is there a way to use fixed-length index in logback's rolling filename pattern?
- html - Why is CSS grid showing two rows instead of one while trying to create a topnav menu? Is using grid for topnav a bad idea?
- node.js - How to set Environment variables on Google Firebase Server
- elasticsearch - Logstash - 如何更改字段类型
- c# - 我正在开发一个合并类游戏。但是碰撞问题?
- javascript - 如何向所有服务器上的频道发送消息
- php - 用于不完整 IP 地址的 REGEX
- javascript - String() 的奇怪行为
- cassandra - 如何强制 Commit log 提交到 memtable?