所以,问题是:
如果我在一个应用程序的密钥链中同时有电子邮件密码和苹果id记录,并且想请求这些数据进行自动登录,我可以获得基于电子邮件密码的帐户信息。
不过,苹果ID并不像预期的那样工作。我接收带有ASAuthorizationAppleIDCredential对象的authorizationCode == nil。我确实接收到了credential.identityToken并可以解码令牌。这是一个有效的方法,但问题是我需要authorizationCode。
如果我使用独立的login函数的AppleAuthenticator,它的工作正常。ASAuthorizationController完美地执行performRequests,我可以从ASAuthorizationAppleIDCredential获得authorizationCode。问题在于AggregatedAuthenticator。ASAuthorizationController似乎已经损坏,如果有多个请求传递给它,它就无法获取所有的数据。
AggregatedAuthenticator(anchor: view.window!).startAutoLogin() // does not work with apple id但
AppleAuthenticator(anchor: view.window!).login() // works唯一的区别是AppleAuthenticator在ASAuthorizationController中只使用一个请求。
我能找到的唯一解决办法是,如果我转到AggregatedAuthenticator并在那里再次登录,请参见代码中的注释:
public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
switch authorization.credential {
case let appleIDCredential as ASAuthorizationAppleIDCredential:
// Question: here we receive the credential without authorizationCode, but why?
appleAuthenticator.login(with: appleIDCredential)
// BUT if I do:
// appleAuthenticator.login()
// it works fine, but it shows that bottom sheet again asking for your face/touch-id again, but only for apple id this time
case let emailPasswordPair as ASPasswordCredential:
emailAuthenticator.login(with: emailPasswordPair)
default:
print("Irrelevant stuff")
}
}有什么想法吗,伙计们?
看看下面的示例代码:
https://github.com/SergeyPetrachkov/ASAuthControllerIssueSample
发布于 2021-11-08 13:42:58
好的,伙计们,这是一个iOS 15回归。以前一切都很正常。
https://stackoverflow.com/questions/69480567
复制相似问题