"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."
"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."
我在使用 Apple Sign In with Firebase Auth 时遇到错误:"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."
我能找到的唯一其他情况类似于以下问题,但是他们更新 pod 文件的解决方案不起作用。
错误:
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 值,在作为参数发送之前显示它们确实相同,添加到适当的请求中,但服务仍然给我这个错误。
BundleID 在 firebase 和 GoogleService-Info.plist 中相同,该应用程序与 Google 登录和 Firebase 一起使用。我试过发送原始随机数、哈希随机数、不同的哈希方法,除了这一点之外一切似乎都还好,而且没有真正的调试方法。
您没有提供 rawNonce
- 您正在使用 accessToken
的方法。
通过执行以下操作修复它:
OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, rawNonce: currentNonce)
,他们说 Xcode 会错误地尝试修复 rawNonce
而使用 accessToken
- 这是不正确的。 pod update
修复了这种情况下的错误。
在 Firebase docs for the iOS SDK 中,他们也像您应该的那样使用带有 rawNonce
的方法。您 不是 想在这里使用哈希随机数,而是您存储在 currentNonce
.
中的值
我在使用 Apple Sign In with Firebase Auth 时遇到错误:"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."
我能找到的唯一其他情况类似于以下问题,但是他们更新 pod 文件的解决方案不起作用。
错误:
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 值,在作为参数发送之前显示它们确实相同,添加到适当的请求中,但服务仍然给我这个错误。
BundleID 在 firebase 和 GoogleService-Info.plist 中相同,该应用程序与 Google 登录和 Firebase 一起使用。我试过发送原始随机数、哈希随机数、不同的哈希方法,除了这一点之外一切似乎都还好,而且没有真正的调试方法。
您没有提供 rawNonce
- 您正在使用 accessToken
的方法。
通过执行以下操作修复它:
OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, rawNonce: currentNonce)
rawNonce
而使用 accessToken
- 这是不正确的。 pod update
修复了这种情况下的错误。
在 Firebase docs for the iOS SDK 中,他们也像您应该的那样使用带有 rawNonce
的方法。您 不是 想在这里使用哈希随机数,而是您存储在 currentNonce
.