【发布时间】:2016-12-27 07:32:17
【问题描述】:
我一直在使用 AWS Mobile Hub 上的 UserPools。我已经设法通过 Facebook 和 G+ 等提供商登录。但是,当尝试使用 AWS UserPools 登录时,我无法这样做。我可以成功注册并完美连接到 UserPool(它识别错误的密码 7 个不存在的用户)。当我使用下面显示的方法登录时,我收到错误:
“检测到 1 个验证错误:'userName' 处的值为 null 未能满足约束:成员不得为 null”
我真的不知道发生了什么,因为用户名和密码实际上是正确的! (即使硬编码)。在这里你可以看到我用来登录的代码:
let pool = AWSCognitoIdentityUserPool(forKey: "UserPool")
let user: AWSCognitoIdentityUser = pool.getUser(textFieldEmail.text!)
user.getSession(textFieldEmail.text!, password: textFieldPassword.text!, validationData:nil, scopes: nil).continueWithBlock { (task:AWSTask) -> AnyObject? in
if task.error == nil {
print("Got: \(task.result)")
} else {
print("Error while logging in: \(task.error?.userInfo["__type"]) with message: \(task.error?.userInfo["message"])")
}
return nil
}
非常感谢您的帮助!我试图添加有关验证数据的信息。比如:
let userName:AWSCognitoIdentityUserAttributeType = AWSCognitoIdentityUserAttributeType()
userName.name = "userName"
iserName.value = textFieldEmail.text
但还是不行。
谢谢!
【问题讨论】:
-
你找到答案了吗?我目前在这里面临同样的问题。这很令人沮丧。
-
不! :(@tyegah123
-
我通过将 SDK 升级到最新版本解决了这个问题。 (2.4.9):D
标签: ios swift amazon-web-services aws-sdk amazon-cognito