How to implement google one tap - One Tap sign-up/sign-in for Android

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll be seeing how to implement Google sign in on Android what we're seeing right now is the end result of what we're going to do in this video when we click on the login Google button you can see that the option to choose the mail account we can select the mail from here and you can see the sign up is successful and you can see a toast message with the mail of the user and second activity showing up so that's what we are going to do in this video okay now let's just go ahead and implement it in the description of this video there is a documentation link to follow this video please open the link we'll be following the documentation click on get started and here we can see the steps so you can see that we have to open the API console so click on it and you'll get the API console screen here we need to create a new project we can give a name for the project you should browse your organization for this example I will not use it just click create OK we can see the project is getting created here we have to make sure that we are on the correct project then next we have to go to the bean Services section click on this and click on auth consent screen here we can select external and click on create in this part we have to fill the application details so let's give the name of the application and a support email also upload the logo I have entered the name of the application given the support email and also uploaded the logo I have added the link to the home page links to privacy policy and the terms if you don't have those links for a test purposes you may skip it for now but you will need it later so you need to create one you need a domain and simply host it I just give my domain here and then we can give the developer contact information after filling these details we can click on Save and continue let's wait for it to complete on this screen we just scroll down and simply click on Save and continue we don't have to add test users yet so click on Save and continue on this summary screen you can simply click on go back to dashboard okay so now our app is ready now let's go back to the documentation we have finished with the first and second stage now we are in the third stage we can see that we have to add this ha1 signature we can just click this or go back to Google Cloud select credentialists make sure that you are in the right project click this create credentials and click the second option that is off client ID and here we have to choose the platform that is Android you can give a name here but let's use the default value the package name we have to obtain the format or Android application so we need to open the Android Studio this is the application that we made in the previous video the link is in the description of this video go to mainactivity Java file and then just copy this for the package name here we have to give this ha1 signature certificate for that you can go to the second documentation link on the description of this video go to the page shown and scroll down copy this command go back to Android Studio click or open Terminal paste it here we have to build first before we execute it OK build is completed now we can execute the command okay now we can see the signature so we are using the debug version also we haven't done the release version.so we are not having those details and we can see the debug version details here okay let's just copy this sha1 select copy and we can go to the Google Cloud then paste the fingerprint here then we can click on create it's creating we can see our client ID and all next just click on OK next we also need to create a web client ID so click on create credentials once more and click on off client ID now this time we have to choose web application you can give a name here but let's keep it to web client 1. we don't have to add these so simply click on create okay creating is in progress okay next we have to copy this client ID and paste it to our Android Studio project so copy this click ok let's go back to Android Studio we need to add the web client ID to strings.xmo go to stringxml file let's add a new string we can name it like server client ID or web client ID and then paste the value that we copied here let's go back to the documentation then scroll down and we can see the dependency we need to copy this line then paste it to our Android Studio project Gradle script here go to the Gradle scripts build Gradle the second one paste the dependency here then we have to click on sync now sync is in progress okay it's finished next let's go back to the documentation now we can go to the create new account with one tap you can find it on the left side so select this option you may read and go through this documentation let's just scroll down until you can see configure the one tap client and we can see the details we need to copy these variables to our main activity copy this variables let's go back to Android studio and go to main activity we can paste it here on the top for this red text we can just import the classes click on import class or press alt shift enter do the same for this one as well next go back to Tay documentation and copy the rest of the code started from here until here block this area and then copy back to Android Studio we can paste it here now for the red text we can import the class click on import class but for this one we need to put our web client ID that we have created previously you remember that we added a string in our string.xml file this one next we need to create an on-click listener for the Google button go back to main activity first let's define our Google button just simply click on import class add Google button here now go back to the documentation and then scroll down in this third section display the one tap sign up UI scroll down to the code part block and then copy the code go back to our Android Studio project in here let's add Google button on click listener and then paste the code here for the red text just click and select import class this one simply just click import class on this just add the activity name on the add-on success listener which is main activity on this failure listener also we need to do the same for this go to the documentation and you can see here let's copy this part then go back to Android studio and paste it here we'll be changing this start intent sender for result function because it is depreciated and will be using the latest methods so let's block and comment this park we will be using activity result launcher method in here I am adding a new object for activity result launcher okay so this is activity result launcher you may refer to the documentation the link is in the description also the source code inside this we have to check if result okay or not and if this is true we can execute the other things like we can get the sign in credentials like email and the user profile Etc so for that we have to start a try catch the documentation have the code so let's go back to the documentation this one create an account with a Google ID token let's copy this code and go back to Android Studio paste it here inside the catch we can do certain things but right now we'll be doing simply print it to the log here we can see that this is fetching the credentials for this data we just need to replace it with result.getdata in this you can get an ID token from Google and further use it to authenticate with your backend but for now we will show a toast message to show the email or username where we can create another activity to show the email or username so let's add this string email equal to credential.getid this will get the mail from the account now let's add a toast message and show the email on the toast message OK this will show the mail next we have to call this activity result launcher scroll down go to Google button on click listener here just delete these lines add this intense sender request new intent sender request dot build then we have to launch the activity for that call the activity result launcher this is the object that we created previously we have to call Dot launch and pass the intent sender request we can see that we are having an error on the try catch so this is saying that we don't need the try catch so either you can click here or type alt shift enter in the keyboard we can see the catch for the class is deleted now let's check if there are still any error looks good our implementation is almost complete now let's add one more string to display I will get the name of the account credential dot get display name we also need to add it in the toes message here we just add username looks like we're ready to do the test we can also add an internet permission on the Manifest go to the Manifest and add uses permission internet okay it's now ready for the test okay it's successfully launching the application if we click the sign in with Google button it will come up with account choices let's select an account and we can see the sign-in is happening we can see the toast message so that means the sign up is completed okay that is the demo hopefully we understand how to implement Google sign in on Android we can add second activity just to display the mail then username if you want the full source code of this project you can go to my GitHub site please check the description of this video if you like this video give it a thumbs up and subscribe to this channel for more such videos thank you see you in our next video
Info
Channel: TutorialMadeSimple
Views: 3,952
Rating: undefined out of 5
Keywords: googleonetap, googlesignin, androidstudiogoogleonetap, androidstudiogooglesignin, androidstudiologin, androidstudiologinactivity
Id: DhugdL10Nb0
Channel Id: undefined
Length: 17min 30sec (1050 seconds)
Published: Mon Sep 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.