首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"MISSING_OR_INVALID_NONCE :请求中缺少了Nonce。“

"MISSING_OR_INVALID_NONCE :请求中缺少了Nonce。“
EN

Stack Overflow用户
提问于 2021-09-17 23:44:35
回答 1查看 918关注 0票数 1

我在使用苹果登录Firebase Auth:"MISSING_OR_INVALID_NONCE : Nonce is missing in the request."时出错

我发现的唯一其他情况类似于下面的问题,但是他们更新pod文件的解决方案不起作用。

在iOS 13上使用Swift设置与苹果的Firebase登录错误的原因?

误差

代码语言:javascript
复制
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.";
}}}}

登录按钮单击方法

代码语言:javascript
复制
    let appleIDProvider = ASAuthorizationAppleIDProvider()
    let request = appleIDProvider.createRequest()
    request.requestedScopes = [.fullName, .email]
    
    let nonce = randomNonceString()
    currentNonce = nonce
    request.nonce = sha256(nonce)

ASAuthorizationController中的剖面

代码语言:javascript
复制
    let firebaseCredential = OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, accessToken: currentNonce)

在设置后,以参数的形式发送之前,打印当前值,显示它们确实是相同的,添加到适当的请求中,但是服务仍然给了我这个错误。

BundleID在Firebase和GoogleServiceInfo.plist上都是一样的,它与Google登录和firebase一起工作。我尝试过发送原始的nonce、散列的nonce、不同的散列方法,除了这一件事情之外,一切似乎都很好,而且没有真正的方法来调试它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-18 00:16:00

您没有提供rawNonce -而是使用了accessToken的方法。

通过执行以下操作来修复它:

代码语言:javascript
复制
OAuthProvider.credential(withProviderID: "apple.com", idToken: identityToken!, rawNonce: currentNonce)

在你的回答中,他们说Xcode会错误地尝试修复rawNonce而不是使用accessToken --这是不正确的。在这种情况下,pod update修复了错误。

在Firebase iOS SDK的文档中,他们也按照您的需要与rawNonce一起使用该方法。您不想在这里使用散列当前,而是使用存储在currentNonce中的值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69230478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档