ios - 处理多个请求时的 ASAuthorizationController 问题
问题描述
所以,问题来了:
如果我的钥匙串中有一个应用程序的电子邮件密码和苹果 ID 记录,并且想要请求该数据进行自动登录,我可以获得基于电子邮件密码的帐户信息。
Apple ID 无法按预期工作。我收到ASAuthorizationAppleIDCredential
对象authorizationCode == nil
。我确实收到credential.identityToken
并可以解码令牌。这是一个有效的,但问题是我需要authorizationCode
.
如果我使用 的独立login
功能AppleAuthenticator
,它可以正常工作。ASAuthorizationController
完美执行performRequests
,我可以authorizationCode
从ASAuthorizationAppleIDCredential
. 问题在于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
解决方案
好吧,伙计们,这是 iOS 15 的回归。以前一切都可以正常工作。
推荐阅读
- angular - ngFor内的Angular 2+ NgTemplateOutlet
- python - AttributeError:'NoneType'对象在使用jupyter notebook的python中没有属性'Mrc'
- kotlin - 什么是惯用的 Corda“协议”流程和状态?
- google-app-engine - 如何在谷歌应用引擎上同步实例数据?
- neo4j - neo4j - 不将关系链接到已创建的节点
- android - 如何设置音频文件的 mimetype,使其在 android 和 ios 上都可以使用?
- python - [Python][Pandas] 高效交叉比较两个groupby列中的值
- reactjs - React - 连续输入的单独框
- javascript - 正/负模数以获取范围内的项目
- r - 比较两列中的值并在 R 或 awk 中重新编码