11

Firebase Authentication allows you to authenticate using auth tokens from other sign in providers (Facebook, Twitter etc). My app is intended to release on iOS and Android. I figured that authenticating with Google and Apple would give me a 99% coverage of all potential users. So far I have found that authenticating users with Google in Unity is a dreadful experience.

https://firebase.google.com/docs/auth/unity/google-signin The Firebase guide about Google auth only gives a guide on how to exchange the Google auth token for a Firebase auth token. Unlike the pages for other Firebase auth providers it doesn't even give a hint as to how you can acquire the Google auth token in the first place, not even mentioning a possible plugin.

https://github.com/googlesamples/google-signin-unity There is a project online that lets a user log in to Google with a Unity project. However, sign in is only possible when the project has been built and run on iOS or Android, it is not possible in the editor. Particularly for iOS, this makes development exhausting. A helpful user posted a workaround so it can run in the editor but this solution seems out of date. If Google was serious about supporting Google sign in it would have added this functionality a long time ago. As it is the project has not been updated in over a year.

https://github.com/playgameservices/play-games-plugin-for-unity Google does seem to be actively developing the Google Play Games api for Unity. However, it no longer supports iOS. Moreover, my app is not a game and this could cause some confusion. I would like users to be able to log into my app with any Google account, not just the current Play Games account.

I'm not sure what to do from here. My searches are growing less and less fruitful. Google does not seem to want developers to be able to implement a sign in solution. Meanwhile Apple is forcefully making their new sign in solution a condition of app store approval. I don't know what to do. Can anybody help?

Phedg1
  • 1,888
  • 3
  • 18
  • 35
  • HI there, I am trying to do the same thing as you, which i'm sure others are, ran into the same articles, and got stuck at the same place as i can't figure out how to get the Google auth token in the first place. Did you manage to solve your problem? – aDvo Feb 06 '21 at 13:39
  • This doesn't directly solve your problem, but I was able to get amazon cognito working with unity. However, I had to use the standard .NET package, since there's no unity plugin made by amazon. Perhaps you can solve it using a .NET solution for google as well? – Adam B Mar 11 '21 at 05:14
  • Two years later and it still is more than just a dreadful experience. I've been spending the last two days trying to figure out how to implement Google Sign-In and I either found incomplete documentations or code that didn't work as it was supposed to. – Cliz Mar 13 '22 at 22:52

1 Answers1

1

Leaving an answer because I could not leave a comment. It might not be an ideal solution for some but definitely a working one. I used PassportJS in my applications to authenticate user sign in.

  • Create a web login page using NodeJS and PassportJS.
  • When user clicks "Login with Google" open this webpage with a device id.
  • After user logs in, associate the logged in user with device id.
  • When user goes back to Unity application ask your web service for associated Google id with the device id.

You can expire this device id from database when a user is logged in to allow a different user to login into same device.

Abhay
  • 11
  • 1