我在使用 Apple 登录和 Firebase 身份验证时遇到错误:"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."
我能够找到的唯一其他情况类似于以下问题,但是他们更新 pod 文件的解决方案不起作用。
在 iOS 13 上的 Swift 中使用 Apple for Firebase 设置登录时出错的原因是什么?
错误:
Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x2807c6ee0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={
code = 400;
errors = (
{
domain = global;
message = "MISSING_OR_INVALID_NONCE : Nonce is missing in the request.";
reason = invalid;
}
);
message = "MISSING_OR_INVALID_NONCE : Nonce is missing in the request.";
}}}}
登录按钮点击方法:
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let nonce = randomNonceString()
currentNonce = nonce
request.nonce = sha256(nonce)
中的部分ASAuthorizationController
:
let firebaseCredential = OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, accessToken: currentNonce)
在设置后打印 nonce 值,在作为参数发送之前显示它们确实是相同的,添加到适当的请求中,但服务仍然给我这个错误。
firebase 和 GoogleService-Info.plist 中的 BundleID 相同,该应用程序适用于 Google Sign In 和 Firebase。我已经尝试发送原始随机数、散列随机数、不同的散列方法,除了这一件事之外,一切似乎都很好,而且没有真正的调试方法。