简体   繁体   English

Unity-将Firebase与Facebook登录一起使用时,SignInWithCredentialAsync导致内部错误

[英]Unity - SignInWithCredentialAsync causes internal error when using Firebase with Facebook Login

I am a Unity programmer and I am using Firebase to manage user accounts. 我是Unity程序员,正在使用Firebase来管理用户帐户。 I tried to set up Facebook Login. 我试图设置Facebook登录名。 No problems with the Facebook sdk and I can log in successfully. Facebook sdk没问题,我可以成功登录。 However, when the credential returned by Facebook sdk is used as a parameter of FirebaseAuth.DefaultInstance.SignInWithCredentialAsync , it returns internal error. 但是,当将Facebook sdk返回的凭据用作FirebaseAuth.DefaultInstance.SignInWithCredentialAsync的参数时,它将返回内部错误。

在此处输入图片说明

And here is my code: 这是我的代码:

void authCallBack(IResult result) {
    if (result.Error != null) {
        Debug.Log(result.Error);
    }
    else {
        if (FB.IsLoggedIn) {
            Debug.Log("Log in successfully.");
            AccessToken token = AccessToken.CurrentAccessToken;
            Credential credential = FacebookAuthProvider.GetCredential(token.TokenString);
            accessToken(credential);
        }
        else
            Debug.Log("not logged in");
    }
}

public void accessToken(Credential firebaseResult) {
    FirebaseAuth auth = FirebaseAuth.DefaultInstance;
    Debug.Log("Auth CurrentUser: " + FirebaseAuth.DefaultInstance.CurrentUser);
    if (!FB.IsLoggedIn){
        return;
    }
    if (auth.CurrentUser != null && !string.IsNullOrEmpty(auth.CurrentUser.UserId)){
        Debug.Log("CurrentUser ID: " + auth.CurrentUser.UserId);
        auth.CurrentUser.LinkAndRetrieveDataWithCredentialAsync(firebaseResult).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted)
            {
                Debug.LogError("LinkWithCredentialAsync encountered an error: " + task.Exception);
                // TODO: Show error message to player
                return;
            }

            FirebaseUser newUser = task.Result.User;
            Debug.LogFormat("Credentials successfully linked to Firebase user: {0} ({1})",
                newUser.DisplayName, newUser.UserId);
        });
    } else {
        auth.SignInWithCredentialAsync(firebaseResult).ContinueWith(task =>
        {
            if (task.IsCanceled || task.IsFaulted) {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception.InnerExceptions[0].Message);
                // TODO: Show error message to player
                return;
            }
            FirebaseUser newUser = task.Result;
            Debug.LogFormat("Credentials successfully created Firebase user: {0} ({1})",
                newUser.DisplayName, newUser.UserId);
        });
    }
}

More details in VS Debugging: VS调试中的更多详细信息:

在此处输入图片说明

When I test it on my Android device, it comes out an error message g_methods_cached only. 当我在Android设备上对其进行测试时,只会显示一条错误消息g_methods_cached

在此处输入图片说明

Can anyone help? 有人可以帮忙吗?

PS Here is another question asked yesterday and I don't know if it is relevant. PS:这是昨天又问的另一个问题,我不知道这是否相关。 FirebaseAuthWebException not found. 找不到FirebaseAuthWebException。 Please verify the AAR 请验证AAR

Oh, I have made a silly mistake! 哦,我犯了一个愚蠢的错误!

In the Facebook Developer page, there is the App Secret in Setting > Basic. 在Facebook Developer页面中,在设置>基本中有应用程序秘诀。 And it has to be added into Firebase Console with the App ID. 并且必须使用App ID将其添加到Firebase控制台。 No problem right now. 现在没问题。 And then...... 接着......

I just copied the App Secret without showing and pasted into Firebase Console. 我只是复制了“应用秘密”,没有显示并粘贴到Firebase控制台中。

Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. 这表示我在Firebase控制台中将8个黑点(●●●●●●●●)设置为我的应用程序密码。 I know it is too silly. 我知道这太傻了。 But just in case there is someone careless like me. 但是以防万一有人像我这样粗心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Firebase 身份验证登录到 Facebook:开发人员错误 - Login to Facebook using Firebase Auth : Developer Error 首先使用 Facebook 进行身份验证,然后使用 Google 进行身份验证会导致 Firebase for Android 出现错误 - Authentication using Facebook at first and then Google causes an error in Firebase for Android 使用Facebook登录到我的应用程序:使用Facebook App时出错 - Login to my app using facebook : error when using Facebook App Android上的Unity Facebook SDK登录错误 - Unity Facebook SDK on Android login error 使用 firebase unity sdk firestore package 时 android 设备出错 - Error on android device when using firebase unity sdk firestore package 在Firebase Facebook登录上获取身份验证失败错误 - Getting Authentication failed error on firebase facebook login 在android中使用firebase登录facebook时出现InflateException - InflateException while login with facebook using firebase in android 在Android中使用Facebook登录时出错 - Error when login with Facebook in Android Facebook Webview登录后出现Unity Facebook SDK致命错误 - Unity Facebook SDK Fatal error after Facebook webview login 在设备上使用Facebook SDK时登录失败的无效密钥错误 - Login failed invalid key error when using Facebook SDK on device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM