Message:

Subscribe rss
Blog categories
All | Backendless features
Create Google Registration and Login Example App with Code Generation
June 13, 2019 by Vladimir Yalovy

Register and Login with Google Code Generation App

Today we are going to walk you through the process of allowing users to register and log into your app using their Google account. The best way to showcase this is to walk though the Registration and Login example app available in the Code Generation section of your Backendless Console.

The first thing we’ll do is create an application with the name Registration_and_Login (you can choose any other name for the application, but then you will need to substitute it further everywhere).

Go to the Code Generation section – select the category Android – Registration and Login.

Android Registration and Login Code Generation

In the window that appears, select only Google login – GENERATE

Generate Google Registration and Login App

Copy the downloaded archive. Open the Archive in your favorite IDE; I use IntelliJ IDEA.

Next you need to click on this link and go to the Configure a section of the Google API Console project. Click on the “CONFIGURE A PROJECT” button and enter the name of your project.

Configure Project in Google API Console

In my example, I chose the following name for the project: BackendlessRegistration. In the next step, I also us the name BackendlessRegistration.

Configure OAuth Client in Google API Console

In the next step, you need to select Android, enter the package name (which can be viewed in the manifest file of the downloaded project in src / main / AndroidManifest.xml). The creation of the SHA-1 signing certificate is described here. After entering all the necessary information, click CREATE.

Configure OAuth Client in Google API Console

After this you will be taken to the next screen, click on Download client configuration. The credentials.json file will be downloaded.

Download Client Credentials

The contents of the credentials.json file are as follows:

From it you need to take the values <client_id>, <project_id>, <client_secret> – open the google-services.json file in the downloaded project and replace its content with the following:

Then you need to go to values / strings.xml and replace two strings:

<string name = "gp_WebApp_ClientId"> </ string>
<string name = "gp_WebApp_ClientSecret"> </ string>

to:

<string name = "gp_WebApp_ClientId"> <client_id> </ string>
<string name = "gp_WebApp_ClientSecret"> <client_secret> </ string>

Now you can bring down the project and run it.

Login with Google App

Before you click the Login button, log in to your Google account on your phone. After logging into your Google account on your phone, return to the application and press the Login button. After a successful login, you will see the following screen:

Completed Login with Google Screen

That’s all, now your application on Android can log in using Google account. Enjoy using Backendless services!

Share this post
Tweet about this on TwitterShare on FacebookGoogle+