Firebase Unity Authentication Support?

1,839 views
Skip to first unread message

Samuel Arminana

unread,
Jan 19, 2017, 12:30:16 AM1/19/17
to Firebase Google Group
Hello everyone, I'm experimenting with Google Firebase Authentication in Unity. I imported the SDK and I've been trying to actually get the authentication to get running for a few days but I'm not sure what to do. I'd like to stay away from Google *Play* Services and use the regular business looking authentication screen.

I've been using the docs located here, https://firebase.google.com/docs/auth/unity/google-signin. The docs seem outdated and some of the variables have been renamed but its error free at the moment.

Upon pressing the login button for google this is called,
       public static void Login_Google(Action Callback)
    {
        Log.Create(0, "Login to google event", "Authentication");

        string access_token = "";
        string id = "IDCODE.apps.googleusercontent.com";
        FirebaseAuth firebaseAuth = FirebaseAuth.DefaultInstance;
        // Login to google and return the key to call the authenticate method
        Credential credential = GoogleAuthProvider.GetCredential(id, access_token);
        firebaseAuth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCompleted && !task.IsCanceled && !task.IsFaulted)
            {
                // User is now signed in.
                Firebase.Auth.FirebaseUser newUser = task.Result;
                Callback();
            }
        });
    }

The Callback() will return to this,

    private void CallbackGoogle()
    {
        Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        Firebase.Auth.FirebaseUser user = auth.CurrentUser;
        if (user != null)
        {
            string name = user.DisplayName;
            string email = user.Email;
            string picture = user.PhotoUrl.AbsolutePath;
            // The user's ID, unique to the Firebase project.
            // Do NOT use this value to authenticate with your backend server,
            // if you have one. Use User.Token() instead.
            string uid = user.UserId;
            string refreshToken = user.RefreshToken;

            Debug.Log("name: " + name + ", email: " + email + ", picture: " + picture + ", uid: " + uid + ", refreshToken: " + refreshToken);
        }
    }

Here's the issue.

I open the app, my log, "Logging into Google Event" is called and I see it in logcat but after that my app crashes and returns to my main menu with the message, "App has stopped working". No error in logcat.

I go back to the docs and notice a little piece that says, "Follow instructions for Android and iOS to get an ID token for the Google sign in."
Great, I click on the Android link and it takes me here, https://firebase.google.com/docs/auth/android/google-signin#authenticate_with_firebase. Well now I need to actually install the package that contains the GoogleSignIn, but there isn't anything for unity.

TLDR; Does anyone know how or if its even possible to add a regular google sign in to unity, (Not the play services login). And is there a package I can download for *UNITY* Google Sign in options?

This isn't extremely urgent but I would like a response on this. Currently facebook is the only authentication service in my app and I'd like to add Google as well. If this isn't possible at the moment someone please tell me so I can begin developing an email/pass authentication service.

Peter Thorndycraft

unread,
Apr 19, 2017, 10:53:17 AM4/19/17
to Firebase Google Group
I do got a little frustrated with this too, the "authenticate with firebase" information does not relate back to Unity so I have no idea how to actually action the login.

Did you get any further with this? I seem to be going round in circles here.

P

Siddharth Verma

unread,
May 17, 2017, 10:50:45 AM5/17/17
to Firebase Google Group
Hi Peter,

I too am stuck in the same loop here.
Did you manage to find any package related to this to get the id and userToken?
I would appreciate if you can help me into this.

matt...@defcongames.com

unread,
May 25, 2017, 10:34:13 PM5/25/17
to Firebase Google Group
Hi Sam, I'm stuck on Google Signin in Unity with Firebase too. The strange thing is that I'm not seeing too many people with this issue online.




Have you found any solution?

Matt Key

matt...@defcongames.com

unread,
May 25, 2017, 10:34:13 PM5/25/17
to Firebase Google Group


On Thursday, January 19, 2017 at 12:30:16 AM UTC-5, Samuel Arminana wrote:

Benjamin Gordon

unread,
Oct 18, 2017, 7:11:19 PM10/18/17
to Firebase Google Group
I know it has been a long time but it still doesn't seem like a thing for this exists. If you are still looking or if anyone comes across this post like I did, I got a working version and wrote a tutorial here, https://github.com/Nomadjackalope/UnityFirebaseGoogleServicesAuth. I will be trying to improve it as I work on it for my own apps as it has some severe downsides but it does seem to work.

Stewart Miles

unread,
Oct 18, 2017, 7:26:21 PM10/18/17
to Firebase Google Group
Oh snap, Clayton (on our DevRel team) recently pushed:

https://github.com/googlesamples/google-signin-unity

This should allow you to sign in using Google Sign-in across iOS and Android, retrieve the token and associated it with a Firebase Auth user.

Cheers,
Stewart

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/3a410065-314a-4ddc-a4bb-e3d9d79d6ba9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Benjamin Gordon

unread,
Oct 19, 2017, 12:14:53 AM10/19/17
to Firebase Google Group
haha! Well, I got some new experience anyhow :) I am really glad that is cross platform and official.

Thanks, I can't wait to get it integrated!
-Ben
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages