我已经使用Auth0 Web登录设置了一个Swift应用程序,一切正常。然后我试图实现" Lock"登录,社交媒体登录的效果非常好,但我无法通过用户名 - 密码方式登录。
在我的Auth0数据库上,已注册的用户显示(表示注册新用户名 - passoword用户实际工作)并在Auth0主页上测试登录本身也可以正常工作。就在尝试使用Lock小部件登录时,我收到一个错误:"我们很抱歉,在尝试登录时出现了问题。"。我也试过验证已注册的电子邮件,但这也没有解决问题。 任何想法,这里可能出现什么问题?
答案 0 :(得分:1)
在将该问题指向Auth0 / Lock支持后,找到了解决方案。也许这有助于人们,遇到同样的问题:在一些VC中使用Lock客户端时:
Lock
.classic()
.withOptions {
$0.scope = "openid profile"
$0.oidcConformant = true
$0.logHttpRequest = true
}
.withStyle {
$0.title = "App Name"
}
.onAuth { credentials in
print("successful login")
}
.onError { error in
print("Failed with error \(error)")
}
.present(from: self)
而不是网络登录:
Auth0
.webAuth()
.audience("https://alienbash.eu.auth0.com/userinfo")
.start {
switch $0 {
case .failure(let error):
// Handle the error
print("Error: \(error)")
case .success(let credentials):
// Do something with credentials e.g.: save them.
// Auth0 will automatically dismiss the hosted login page
print("Credentials: \(credentials)")
}
}
必须确保改变" Grant_Type" Auth0客户端设置也允许"密码"格兰特。为此,请在Auth0客户端中转到:
设置 - >进展设置 - >拨款类型
并确保检查"密码,因为在创建新的Auth0客户端时默认情况下取消选中此复选标记,并且在使用" Lock"时不可避免。客户。