我正在使用Xamarin.Firebase.iOS.Auth和Apple AuthenticationServices来允许用户使用Apple Sign In
登录并随后通过Firebase进行身份验证。我有一个Xamarin.iOS
应用程序,并且Apple Sign In
部分已完成,没有任何问题,我能够激活Apple Sign In
并从ASAuthorizationAppleIdCredential接收有效的身份令牌。问题出在第二步,当我尝试使用该令牌向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;
}
);
起初我以为令牌无效,但是后来我尝试使用本机Swift示例中先前收到的相同令牌(从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
})
本机和Xamarin应用程序都是相同的,具有相同的配置,相同的包ID和相同的功能。我发现的唯一区别是组件版本。 Firebase本机组件是:
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应用程序特有的另一个配置问题?