Firebase Tutorial: Adding Google Play Games Auth to Unity

preview_player
Показать описание
This tutorial covers everything you need to do to set up a Unity Game to use Google Play Games Auth to sign into Firebase.

Here are the links for the sections:
Рекомендации по теме
Комментарии
Автор

Here's the code, so you don't have to type it out:

using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using Firebase.Auth;

public class SignInOnClick : MonoBehaviour {

// Use this for initialization
void Start () {
// Initialize Play Games Configuration and Activate it.
PlayGamesClientConfiguration config = new
.RequestServerAuthCode(false /*forceRefresh*/)
.Build();

PlayGamesPlatform.Activate ();
Debug.LogFormat ("SignInOnClick: Play Games Configuration initialized");
}


public void SignInWithPlayGames () {
// Initialize Firebase Auth
Firebase.Auth.FirebaseAuth auth =

// Sign In and Get a server auth code.
((bool success) => {
if (!success) {
Debug.LogError ("SignInOnClick: Failed to Sign into Play Games Services.");
return;
}

string authCode = ();
if (string.IsNullOrEmpty (authCode)) {
Debug.LogError ("SignInOnClick: Signed into Play Games Services but failed to get the server auth code.");
return;
}
Debug.LogFormat ("SignInOnClick: Auth code is: {0}", authCode);

// Use Server Auth Code to make a credential
Firebase.Auth.Credential credential =

// Sign In to Firebase with the credential
=> {
if (task.IsCanceled) {
Debug.LogError ("SignInOnClick was canceled.");
return;
}
if (task.IsFaulted) {
Debug.LogError ("SignInOnClick encountered an error: " + task.Exception);
return;
}

Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat ("SignInOnClick: User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId);
});
});
}
}

firebasefan
Автор

i paired this with another tutorial by some russian dude and was able to get everything working, thank you!

for those having issues connecting to google play, try using the Upload key certificate, you can find it at the bottom of the page when searching "upload" in google play console and selecting "App integrity"

stefan
Автор

THX THX THX THX OMFG THIS GUIDE WITH SCREENSHOTS AND ARROWS WAS VERY VERY HELPFUL! I tired to resolving my problems, you saved me.

eloreneloreneloreneloreneloren
Автор

Thank you, very easy to follow and nice pace of speaking

funduino
Автор

5:47 The directory shown in the picture is wrong, the google-services.json file needs to be inside the "Assest" folder of your project !

entertainment
Автор

Google Play Sign In was work at bluestack but open My game with any android device, sign not work ı dont know why like this ?

unrealcoder
Автор

Thank you for the helpful video. It was very clear and concise to follow (still stuck at resolving dependencies though :( ). One suggestion for future is to also include the useful links in the description.

PieterMulder
Автор

Hello. Thanks for your tutorial. I have tried everything and still getting this error with the app crashing. Can you help?
10-28 18:05:51.908: E/Unity(31919): Java class not found. Please verify the AAR which contains the class is included in your app.

dimitriosgargeros
Автор

Hi, I have followed all your steps carefully but I am unable to login. The error just says "Authentication Cancelled". can you help please!

parvezawan
Автор

after a whole day try and error this finally work for me. relay helpful.

vwgamedev
Автор

i successfully play games signed in in my phone but i can't see user in firebase ? what is the problem? if i cant see user, How can i manage the database or high score or coin for the this user?

millgames
Автор

I am stuck in Resolving Android Dependencies. It all started after Unity notify me that some stuff in the package are obsolete and ask me if I want to delete them. So, I clicked 'yes' and now stuck in RAD.

oszy
Автор

Hi, is there any chance you could do a tutorial for the Google Login Auth?

wizardsofscript
Автор

I made all the settings but "Failed to Sign into Play Games Services." see. Can you tell me how to fix it? My error log is this "INVALID_CLIENT_ID"

muncleg
Автор

it is possible to get player gmail address in firebase????

adhilsuresh
Автор

Thank you for this tutorial. I get an error message in my console The type 'Task<>' is defined in an assembly that is not referenced. You must add a reference to assembly. Do you have a solution? Best regards

pescogames
Автор

Thank you very much for this tutorial!

Videogueimeiro
Автор

GetServerAuthCode() keeps returning null.

Any idea where i might have gone wrong ?

mariofigueiredo
Автор

Thank you very much for this tutorial!! Helped me a lot!! One question, how do I hide the sign in button after I authenticate my google account?

troymelo
Автор

Thank you so much for the is really helpful.

patrushtamang