我在使用苹果登录Firebase Auth:"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."时出错
我发现的唯一其他情况类似于下面的问题,但是他们更新pod文件的解决方案不起作用。
在iOS 13上使用Swift设置与苹果的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)在设置后,以参数的形式发送之前,打印当前值,显示它们确实是相同的,添加到适当的请求中,但是服务仍然给了我这个错误。
BundleID在Firebase和GoogleServiceInfo.plist上都是一样的,它与Google登录和firebase一起工作。我尝试过发送原始的nonce、散列的nonce、不同的散列方法,除了这一件事情之外,一切似乎都很好,而且没有真正的方法来调试它。
发布于 2021-09-18 00:16:00
您没有提供rawNonce -而是使用了accessToken的方法。
通过执行以下操作来修复它:
OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, rawNonce: currentNonce)在你的回答中,他们说Xcode会错误地尝试修复rawNonce而不是使用accessToken --这是不正确的。在这种情况下,pod update修复了错误。
在Firebase iOS SDK的文档中,他们也按照您的需要与rawNonce一起使用该方法。您不想在这里使用散列当前,而是使用存储在currentNonce中的值。
https://stackoverflow.com/questions/69230478
复制相似问题