How to : Integrate Google Play login into your Unity project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody my name is Alex and today I'm going to show you how to implement Google Play and Google Play login inside your Unity project I'm doing so because I tried implementing Google myself and it's a very tiresome process why because unity and Google did not update your documentation on this matter and they have old code with new documentation and new documentation of the old code it's a mess and I don't want you to go to that mess therefore today I am going to take you step by step into the process of implementing Google Play login inside your Unity project I just opened a Unity project it's empty there's literally nothing in it except ASAP or scene I want to show you and I want to guide you the whole process first of all open up build settings we are building for Android Google Play is on Android therefore please switch Unity project to Android go Android switch platform after you switch the platform here at the name of the project and the scene it should also say Android go to edit go to Project settings first of all we have to link our project ID our project that we plan to use Google with the way this works is Unity here your immunity we have to link our Unity project with a Unity dashboard project what's that well Unity dashboard is this it's part of Unity gaming services and Unity gaming Services is a service that gives you access to a lot of options like analytics build automation Cloud saving and guess what authentication we need authentication to be able to access Google Play right because logging with Google play requires a form of authentication and you'll have to create a project I already have a few projects here but I'm going to use this project for our tutorial I'm not going to show you the whole process of creating a company you have to create a company and also creating a project because it's easy and if you are watching this tutorial you probably know how to create this go back to Unity select the organization how and why does my organizations appear here because it is all decided by unity Hub the email reconnected with in unity Hub and I am connected with if I press account settings it's going to open up a browser and tell me some information I have this email and if we go to Unity project here I'm also having the same image so make sure that you sync your emails across the platforms go down here I'm going to select my little Cloud Studios organization and I'm going to use an existing Unity project ID because I already created one here test project if I haven't created one I would be using Create project ID using existing select my data Cloud Studios and select the project being test project and then don't forget to press link because you have to create a connection between unity and unity dashboard link project ID yes and now as you can see everything here is linked accordingly Next Step go to player set up your company name here I'm gonna have it as this company and the project name is gonna be will gain collapses we are only going to be using two tabs here other settings and Publishing settings let's first start with other settings scroll all the way down to identification and package name as you can see this box is not checked therefore it's going to use the default package name but I can show you how not to use that check this one and edit the package name as you'd like but I will use the default one next make sure the scripting backend is selected to as il2cpp it's very important it's faster and this is what Google supports also make sure you're using arm 64 that's important because almost any other store now uses 64 technology with these settings in mind please scroll down all the way to publishing settings in publish settings what is very important to keep in mind is that Minify is disabled nothing here is enabled make sure you have the exact same checks as I do here the next thing we have to do is creating a keystore what is a keystore that's a very good question a key story is an unique identifier between your application and Google a best practice is having a development key store and a release keystore we're going to create a custom kisser go towards keystore manager keystore create new anywhere I usually what I do is I create a new folder inside the main folder of the game before the key store and here I create the dev key store I'm not going to be creating the release keystroke for this tutorial because it doesn't have any value save and the password I'm going to add the password right now the Alias is just a username whatever for your key you can name it as what you'd like the password and you can have the same password which is not not an issue with this but for secret reasons you should have different passwords I don't really care because it's a test tutorial the first and last name just you can use for the company here City locality I'm gonna put liquorice because that's where I'm headed and for the country code you have to find your country code online add key and then yes add the key make sure that you have it selected over here in test keystore devkey store it already added the password and the password we are good to go after you've completed this step you have to go to play dot google.com so go to this link and you are going to be prompted with a login for a Google Play developer account I'm going to choose my account which is radical Studios and I kind of show you that process but you are going to be prompted with some beginning questions and also you have to pay the 25 dollar fee for publishing on the Google Play Store that fee includes an unlimited number of apps so it's a one-time purchase of 25 but it's a lifetime of publishing apps on the Google Play Store you're going to be presented with this after you complete the onboarding all apps spin apps whatever go to create app and let's create our app the app name is how it will appear on Google Play I'm going to put it as that's me because it will never see the lights update this is a game it's not an app and if you're up 8 it's free paid whatever you have but I'm gonna go with free I confirmed this at mids and I confirmed that I accept use us export laws and go to create app you have created your app now you can ignore all these tasks for now scroll all the way down to play game Service setup and management configuration this is where the magic happens you're going to be granted with three options well if your game already uses an API like Firebase which is rated Google Google has already other apis apis if you use any Google API check this one if your game doesn't use any API check this one but if you already have a project that you want to use Google Play check the third option for us is the second option we don't use any Google apis game name is that's me go create okay we are up and running we have our first Google Play application in the console let's follow the steps first of all you have to create an auth constant screen you are going to be prompted with this pop-up and go to Google Cloud platform I know very good UI from the Google team now choose how you want to configure and registry app well our first app is not gonna have anything to do with internals we just have external testing everybody has access to it not just people from my organization go create app name let's call this destiny I call it you can call it whatever it's not important right now I call it like this because it's only on the dev environment I have this it's very important that you differentiate between a Dev environment and a release environment these are support email is just this a Blog control do not add an app logo here don't add the app domain don't add anything and developer contact information and whatever it may be on there and go save and continue Scopes here very important that you add those three following Scopes either remove Scopes and select Google Play game services Google Play game Services light and also Google Play game services with the app data hit update we have this tree here and go save and continue test users make sure that you add yourself as a user here don't forget this step because this is this is very annoying without having a test user here you are not going to be able to test your Google Play application and also make sure that this user that you're using is the mail that you have connected on your phone to Google Play that's really important okay we have created the odd screen go back to the dashboard go to configuration config configuration we have created the configuration but you also have to create two credentials when Android credential and the game server credential let's first start with the game server as it is easier at credential game server it's a test me one and now we also have to create an all auth client because a credential uses an or auth client we don't have one so click on create after you're done with this pop-up create auth client ID application time is web application name it whatever you want whatever name there's the web and just click create make sure that you download the Json close this close this close this one done refreshold clients and back into where you've created the web application add the test me web and save changes and now if you go back to configuration at the credential step we're gonna have a game server created now let's also create an Android one add credential select Android call it test me enable anti-piracy make sure this is off because if you select this to on then you will not be able to test your application why because when downloading when testing will build you're going to be downloading it from not Google Play basically from the web from other sources and that's counted as previously make sure it's off now we also have to create an all-out client for this one so click create auth client and the application type is going to be Android name now this is a specific part of the process we need the package name what is the package name go back to Unity go to other settings scroll down this is the packaging copy it and paste it here now this sha-1 certificate is going to give you headaches it also gave me headaches in order to get this certificate you need the key store that we created earlier this this thing over here now how do you get a code like this from the keystore that's a very important question Point Java on your computer for me that's located at this PC in program files x86 Java bin this is the pro this is the folder you have to arrive at for other people is basically just at local DC and program files is one of these two folders find your Java folder and go to it here make sure you copy this address open up a command prompt and TP to these address so now we are in that folder now go to guitar select browse go to where your key store is located now copy this location and type the following code Dash restore paste the location of the keystore followed by the keystore name in our case delete that keystore followed by this followed by B enter we are going to be prompted with the keystore password enter and you've gotten your sha1 fingerprint this is the fingerprint we need copy it close this one go here and paste it we have our development fingerprint create download Json now going back to the game configuration let's refresh the appliance and add Desmond Dev save changes and if you go back to configuration the main screen in your application you're going to see one Android credential and one game server credential well that's great for now we are finished with play games Services configuration and you search for Google Play login Unity yeah I know that's a very important aspect go here you're going to have all these links in the description below this is a plugin that Google put for Unity go to code and download zip open this and make sure you exert this one somewhere the desktop go to desktop go to where it was extracted and you only need the current build I'm going to have one Unity package here double click it and it's going to add this unit package inside our project without this plugin we cannot use Google hit import after important package make sure you also enable the Android auto resolution I assure you from now that this is probably going to say build failed but that's okay it usually does that now go to window Google Play games setup and reset the directory received constancy is basically where we want to save the constants and the constants class name yeah you can use that whatever we can change this after you understand how it works we need to informations the first one is something and the second one is something let's go to the second one because it's easier to find open up the Boulder where you kept your web app Json open the web app Json and first things first copy the client ID copy close it here and paste it into client ID now here you have to go back to Google play at configuration go to get resources in play game Services setup and management configuration get resources and just copy this thing paste it download it copy this thing paste it here and set up okay so now I've set up Google Play games that's good now the resolving entry dependencies is going to run by itself shouldn't find any errors now hopefully and if you even if it does it's still most likely okay one of the last settings got window package manager go to unit registry again and search for authentication and download the package install the package after we downloaded this package go to edit purchase settings and services you should see authentication go to notification add a Google Play games identity provider edit and we need the client ID [Music] which is again this one copy it paste it and also need the client secret which is at the end of the Json copy this one as well paste it here and hit save and now we also have a connection with Google play games and that's great if you go to the unity dashboard the way uh live Ops and authentication about sorry identity providers you are going to see your application link to Google play games and then the status of enabled that's great now I have a script ready go to create empty Google and the script here the script is empty we just have to add some code you are going to have the script in the description down below but I suggest you to pay attention to what it does and what every single thing that I'm going to do means it's supposed to create a public string we're going to play token this is a token that we're going to get from Google Play on successful login we also going to have a public string Google Play error in case Google Play throws an error we have to know what error we have now we have an issue here the thing that in version 0.10 of the Google Play plugin which we have it right here got the games this plugin the code implementation was totally different in the 0.10 implementation you were able to manually authenticate to Google Play remember the games where you just have to go hey I hit authenticate now this doesn't happen it's an automatic sign in as well also quick tip you cannot test Google Play services here you cannotize web services in editor only on a build on Android then let's go ahead and create a public let's sync desk first of all let's go play games platform that activate so we activate the actual play games Unity Unity services that initializing so we also connect to the unity API and now let's do a play games platform that instance that authenticate okay let's see success that if success equals sign in status success then let's do something here let's give debug so basically debug them debug DOT log in with Google Voice suck after that let's create play games platform that instance dot request server-side access this change in the last plugin version this is the actual correct updated usage true I have a code and create this uh let also to add debug log art codes is auth code is go and then do a Google Play Google Play token equals now on the other hand if it's not successful then let's do a in Google Play error is failed to receive oops leave Google play games of code Android debug that load error login on alright so we have this this connects to Google like this part of that connects you will play games with the unique dashboard and so after you send your DLP games also do a open decades with infinity let's create this method which is a private a sync desk and this authenticate opportunity is just going to try I'm gonna do when a weight of the authenticate or 10 application service but instance that sign in with Google async and we need the codes that we're sending with right so the token and debugger blog for the information that you need I'm gonna take that here we have an exception which is apply authent authentication exception X debug pick up log instructions and you also have another catch but this time we have a different exception called request fail exception I suggest you adding this is going to help you and just Pro not like this but like this bro and so basically right after you connect to Google Play games also connect with unity and you have to avoid this and there's a code now go ahead and make a build for this hit build create it wherever I'm going to create it here builds a test after the build was successful make sure you only send this test.apk only the APK file to your mobile phone and see you on mobile testing the Google pay integration
Info
Channel: QuickDev
Views: 9,625
Rating: undefined out of 5
Keywords: unity, google play, tutorial
Id: dbLpA2YB6vU
Channel Id: undefined
Length: 25min 13sec (1513 seconds)
Published: Fri Jul 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.