Solved - Unity SignInWithCredentialAsync causes internal error when using Firebase with Facebook Login











up vote
1
down vote

favorite












I am a Unity programmer and I am using Firebase to manage user accounts. I tried to set up Facebook Login. No problems with the Facebook sdk and I can log in successfully. However, when the credential returned by Facebook sdk is used as a parameter of FirebaseAuth.DefaultInstance.SignInWithCredentialAsync, it returns internal error.



enter image description here



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:



enter image description here



When I test it on my Android device, it comes out an error message g_methods_cached only.



enter image description here



Can anyone help?



P.S. Here is another question asked yesterday and I don't know if it is relevant.
FirebaseAuthWebException not found. Please verify the AAR










share|improve this question




























    up vote
    1
    down vote

    favorite












    I am a Unity programmer and I am using Firebase to manage user accounts. I tried to set up Facebook Login. No problems with the Facebook sdk and I can log in successfully. However, when the credential returned by Facebook sdk is used as a parameter of FirebaseAuth.DefaultInstance.SignInWithCredentialAsync, it returns internal error.



    enter image description here



    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:



    enter image description here



    When I test it on my Android device, it comes out an error message g_methods_cached only.



    enter image description here



    Can anyone help?



    P.S. Here is another question asked yesterday and I don't know if it is relevant.
    FirebaseAuthWebException not found. Please verify the AAR










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am a Unity programmer and I am using Firebase to manage user accounts. I tried to set up Facebook Login. No problems with the Facebook sdk and I can log in successfully. However, when the credential returned by Facebook sdk is used as a parameter of FirebaseAuth.DefaultInstance.SignInWithCredentialAsync, it returns internal error.



      enter image description here



      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:



      enter image description here



      When I test it on my Android device, it comes out an error message g_methods_cached only.



      enter image description here



      Can anyone help?



      P.S. Here is another question asked yesterday and I don't know if it is relevant.
      FirebaseAuthWebException not found. Please verify the AAR










      share|improve this question















      I am a Unity programmer and I am using Firebase to manage user accounts. I tried to set up Facebook Login. No problems with the Facebook sdk and I can log in successfully. However, when the credential returned by Facebook sdk is used as a parameter of FirebaseAuth.DefaultInstance.SignInWithCredentialAsync, it returns internal error.



      enter image description here



      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:



      enter image description here



      When I test it on my Android device, it comes out an error message g_methods_cached only.



      enter image description here



      Can anyone help?



      P.S. Here is another question asked yesterday and I don't know if it is relevant.
      FirebaseAuthWebException not found. Please verify the AAR







      android facebook firebase unity3d






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 8:48

























      asked Nov 22 at 4:17









      Jacky Hon

      215




      215
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Oh, I have made a silly mistake!



          In the Facebook Developer page, there is the App Secret in Setting > Basic. And it has to be added into Firebase Console with the App ID. No problem right now. And then......



          I just copied the App Secret without showing and pasted into Firebase Console.



          Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. I know it is too silly. But just in case there is someone careless like me.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423835%2fsolved-unity-signinwithcredentialasync-causes-internal-error-when-using-fireba%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Oh, I have made a silly mistake!



            In the Facebook Developer page, there is the App Secret in Setting > Basic. And it has to be added into Firebase Console with the App ID. No problem right now. And then......



            I just copied the App Secret without showing and pasted into Firebase Console.



            Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. I know it is too silly. But just in case there is someone careless like me.






            share|improve this answer

























              up vote
              0
              down vote













              Oh, I have made a silly mistake!



              In the Facebook Developer page, there is the App Secret in Setting > Basic. And it has to be added into Firebase Console with the App ID. No problem right now. And then......



              I just copied the App Secret without showing and pasted into Firebase Console.



              Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. I know it is too silly. But just in case there is someone careless like me.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Oh, I have made a silly mistake!



                In the Facebook Developer page, there is the App Secret in Setting > Basic. And it has to be added into Firebase Console with the App ID. No problem right now. And then......



                I just copied the App Secret without showing and pasted into Firebase Console.



                Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. I know it is too silly. But just in case there is someone careless like me.






                share|improve this answer












                Oh, I have made a silly mistake!



                In the Facebook Developer page, there is the App Secret in Setting > Basic. And it has to be added into Firebase Console with the App ID. No problem right now. And then......



                I just copied the App Secret without showing and pasted into Firebase Console.



                Which means I have set 8 black dots (●●●●●●●●) as my App Secret in my Firebase Console. I know it is too silly. But just in case there is someone careless like me.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 8:47









                Jacky Hon

                215




                215






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423835%2fsolved-unity-signinwithcredentialasync-causes-internal-error-when-using-fireba%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks