gpt4 book ai didi

ios - Firebase 身份验证尝试使用 Apple 的身份 token 会在 Xamarin.iOS 应用程序中返回 17999 INVALID_CREDENTIAL_OR_PROVIDER_ID

转载 作者:行者123 更新时间:2023-12-02 04:04:30 26 4
gpt4 key购买 nike

我正在使用Xamarin.Firebase.iOS.Auth和苹果AuthenticationServices让用户使用 Apple Sign In 登录,然后使用 Firebase 进行身份验证。我有一个 Xamarin.iOS 应用,并且 Apple Sign In 部分已完成,没有任何问题,我能够激活 Apple Sign In 并接收来自 ASAuthorizationAppleIdCredential 的有效身份 token 。问题出在第二步中,当我尝试使用该 token 通过 Firebase 进行身份验证时:

var idTokenString = "<my_valid_identity_token_here>";
var credentials = OAuthProvider.GetCredential("apple.com", idTokenString);
var authResult = await Auth.DefaultInstance.SignInWithCredentialAsync(credentials);

我收到了包含以下详细信息的异常:

(Inner Exception #0) Foundation.NSErrorException: 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=0x600002c89260 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={
code = 400;
errors = (
{
domain = global;
message = "INVALID_CREDENTIAL_OR_PROVIDER_ID : Invalid IdP response/credential: http://localhost?providerId=apple.com&access_token=<my_token_here>";
reason = invalid;
}
);

起初我认为该 token 无效,但后来我尝试在 native Swift 示例中使用之前收到的相同 token (从 xamarin 应用复制/粘贴),并且我能够使用 Firebase 进行身份验证,没有任何问题:

let appleIDToken =  "<my_valid_identity_token_here>";
let credential = OAuthProvider.credential(
withProviderID: "apple.com",
idToken: appleIDToken,
accessToken: nil)

Auth.auth().signIn(with: credential, completion: { (authResult, error) in
// error = nil!, authResult - OK
})

native 应用程序和 Xamarin 应用程序是相同的、相同的配置、相同的 bundle ID、相同的功能。我发现的唯一区别是组件版本。 Firebase native 组件有:

FirebaseCore (6.5.0)       vs    Xamarin.Firebase.iOS.Core (6.1.0)
FirebaseAuth (6.4.1) vs Xamarin.Firebase.iOS.Auth (6.2.1.1)
FirebaseFirestore (1.8.3) vs Xamarin.Firebase.iOS.CloudFirestore (1.4.2.1)

是否可能是 Xamarin 提供的过时版本存在问题,或者可能存在特定于 Xamarin.iOS 应用程序的其他配置问题?

最佳答案

事实证明,Xamarin 组件的版本号与 Google Firebase SDK 不同,Xamarin.Firebase.Core.iOS 6.1.0.0 版本对应于最新的 FirebaseCore 6.5.0:

https://github.com/xamarin/GoogleApisForiOSComponents/blob/master/components.cake#L122

应用程序中的问题与 API 接口(interface)定义有关,以下行将 idTokenString 值作为访问 token 传递

var credentials = OAuthProvider.GetCredential("apple.com", idTokenString);

所以我改用另一个重载并且效果很好:

var credentials = OAuthProvider.GetCredential("apple.com", IdToken: idTokenString, accessToken: null);

关于ios - Firebase 身份验证尝试使用 Apple 的身份 token 会在 Xamarin.iOS 应用程序中返回 17999 INVALID_CREDENTIAL_OR_PROVIDER_ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59434844/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com