Saturday, December 26, 2015

Sign in using Google with Liferay

Below is the step to login into Liferay Portal using google. It will create a user with your gmail user name in your liferay portal and let you login and navigate to dashboard page without login with login portlet of Liferay.

First Setup your web application for Google+ OAuth2 API.
Step 1 : Go to Google Developers Console and login with your google credentials. At top right corner you will see create project option as shown in screen below. Create a project by clicking on the Create project link.
Image 1

 Step 2 : A popup will appear as shown below : 
Image 2
give your project name, Your project id will auto populate for you but if you want you can edit it by clicking on edit link given. Click on create button to create the project.
Next, you will be redirected to your Project’s DashBoard page as shown below.
Image 3
in the above image in the highlighted area click on the box to enable Google Apis that you need it.
It will take you to apis liberary page as shown below : 
Image 4


.
In the above image i have point with arrow to create credential in  APIS & AUTH-> Credentials.
When you click on OAth Client Id option from select it will take you to below screen :
Image 5
You must be seeing a warning message to set a product name on the consent screen. For this we have to go to OAuth consent screen. As shown below :
Image 6
Here just give your product name only as others fields are optional so leave as it is and click on save button it will take you to Image 4 so When you click on OAth Client Id option from select it will take you to below screen :
Image 7
Fill the detail as shown above and click on create button. a popup will come to you as shown below:
Image 8
Finally, CLIENT ID and CLIENT SECRET is created.

Any time you can edit this setting by clicking on your created credential as shown below : 
Image 9
Now we have done with client id and client secret key creation.

Step 2: Next you have to purchase Google Login App from Market place and install in your application. Here is the Link.
once you install Google Login App you can see Google link as shown below :
Image 10
Step 3: Now you we have to provide our client id and client secret key to our portal.
for that go to Control Panel > Portal Setting and in the right panel click on Authentication Link.
You will see screen as below :
Image 11


click on google tab and there provide your client id and client secret key.
That's All we have done all the step to integrate. Now you sign out and try clicking on google link in your login portlet to sign in its will create new user with your gmail user name and let you login.

Note : you can change your domain name in host file as 
1.27.0.0.1 yourdomainname.com


then restart your system.