Firebase Auth. – Google Sign In

Through user testing and survey results, Google won as the preferred sign-in provider. Users prefer using providers like Google, FB, Twitter, etc. for signing in because it is quicker to just use an existing account rather than having to go through the sign-up process.

Google sign-in can be achieved in 2 ways, either directly through Google Developers or through Firebase. Through Google Developer, besides setting up the project and whatnot, there are a number of limitations and details that need to be provided. The main reason I decided against Google Developers is because it works using the Google Play API Auth method which would limit sign-ins to Android users or devices with Google Play, so it would not work for iOS devices. Secondly, when creating an OAuth credential, it isn’t cross-platform, so you need to set-up for both Android and iOS. Androids require things called client-id and client-secret which are keys that need to be placed in code etc. I couldn’t get the client-secret.

Also, Androids require something called a SHA-1 key so that an OAuth client and API key could be made for the app. This was a hassle to create. Usually, when downloading the Android SDK, it comes with a keystore which you can use to find the key. However, mine didn’t, and it was missing other essential files like the JAVA folder etc. which all needed to be then manually set-up and linked. I created a custom keystore through Unity and then ran a command using the keytool utility provided by JAVA to get the all the keys I needed.

Using Firebase, first the Unity app needs to be set-up in Firebase. I chose both Android and iOS as i’m developing my app for both and provided the SHA-1 key. Then there are certain files that need to be downloaded from Firebase and imported into the Assets folder of the Unity project. The Firebase Unity SDK also needs to be imported, mainly the FirebaseAuth file. Once all this is setup, all that is left is the code, yay~ The code was actually a breath of fresh air – it was straightforward, easy to implement, and most importantly easy to understand.