[英]Auth0 “Lock” for Swift Username-Password Login not working
I have set up a Swift App with the Auth0 Web Login and everything works fine. 我已经使用Auth0 Web登录设置了Swift应用,一切正常。 Then i have tried to implement the "Lock" login with the result that social media login works perfectly well, but i cannot login via the username-password method. 然后,我尝试实现“锁定”登录,结果社交媒体登录可以很好地工作,但是我无法通过username-password方法登录。
On my Auth0 database, the signed-up user shows up (indicating that sign up of new username-passoword user actually work) and testing the login itself on the Auth0 Homepage works fine as well. 在我的Auth0数据库上,会显示已注册的用户(表明新用户名密码用户的注册确实有效),并且在Auth0主页上测试登录本身也可以正常工作。 Just when trying to login with the Lock widget, i get an error: "We're sorry, something went wrong when attempting to log in.". 刚尝试使用Lock小部件登录时,出现错误:“很抱歉,尝试登录时出了点问题。” I also tried verifying the registered E-Mail, but that did not solve the issue either. 我也尝试验证已注册的电子邮件,但这也不能解决问题。 Any ideas, what might go wrong here? 任何想法,这里可能出什么问题?
After also pointing that issue out to Auth0/Lock support, a solution was found. 在也指出该问题为Auth0 / Lock支持之后,找到了解决方案。 Maybe this helps people, having the same problem: When using the Lock client inside some VC: 也许有同样的问题,这可以帮助人们:在某些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)
instead of the web login: 而不是Web登录:
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)")
}
}
one has to make sure to change "Grant_Type" the Auth0 client settings to also allow the "Password" Grant. 必须确保更改Auth0客户端设置的“ Grant_Type”,以同时允许“密码”授予。 In order to do that, in your Auth0 client go to: 为此,请在您的Auth0客户端中转到:
Settings --> Advances Settings --> Grant Types 设置->高级设置->授予类型
and make sure to check "Password as this checkmark is unchecked by default when creating a new Auth0 client and will be inevitable when using the "Lock" client. 并确保在创建新的Auth0客户端时默认选中“密码,因为此复选标记未选中,在使用“锁定”客户端时将不可避免。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.