Introduction
Integrating Google Login with Liferay enhances the user experience by enabling seamless and secure authentication using Google credentials. This integration allows users to bypass traditional login methods, reducing friction and improving convenience. By leveraging OAuth 2.0, Liferay connects with Google as an identity provider, ensuring secure and efficient authentication. This feature simplifies user access and streamlines account management for administrators, offering a modern and user-friendly approach to authentication in digital experiences. Perfect for businesses prioritizing usability and security, Google Login integration with Liferay is a must-have feature for today’s dynamic web platforms.
Prerequisites
- Liferay DXP/Portal 7.X
- Basic knowledge of Liferay
Environmental Requirements
- Liferay Portal or DXP
- OpenJDK
Steps to Integrate Google Login in Liferay
Set up Google + OAuth2 API Access
Integrate this API with Liferay
1) Set up Google + OAuth2 API Access
- Navigate to the Google Developer Console by clicking here. Log in using your Gmail credentials. Once you’re logged in, click on Select a Project in the top navigation bar, and then choose the option to Create a New Project.
- Now Enter your project name and organization as shown in the image below.
- After creating the project, Navigate to the Credentials page in the left-hand side menu.
- Click on the Create Credentials > OAuth client ID > Configure Consent Screen
- Now carefully read both of the User Types, select one that completely matches your requirements, and click on the Create button.
- Now add your App name and User support email address.
- Now add all the required details below on this page.
- Now add test users if you are integrating this for testing purposes and this is a good practice as a developer.
- I have added two test users as you show in the above image.
- Now it is time to navigate to the Credentials and select your created project.
- Now Create Credentials > OAuth client ID > Application Type > Web Application
- Once you select Web Application, you need to add the main page URL and redirect page URL as you show in the above image.
- Main page URL or Authorized JavaScript origins
http://localhost:8080
- Redirect page URLs or Authorized redirect URIs
http://localhost:8080/c/portal/login/openidconnect
- Now click on create and you will be shown one popup window with client ID and client secret.
- As shown in the above image, you will receive a Client ID and a Client Secret, which are essential fields required to integrate Google login.
- Please copy both fields and save them securely, as these are required to integrate Liferay with Google.
- You can also download the JSON.
- All steps on the Google side have been completed; now, it’s time to integrate the API with Liferay.
2) Integrate this API with Liferay
- Open your Liferay portal and log in using your admin credentials.
- Go to the Control Panel > Instance Setting > SSO
- Navigate to the OpenID Connect section, enable the required fields, and save the changes.
- Click on the OpenID Connect Provider Connection and fill in the required fields as you show in the above image.
- Please enter the URL below into the Discovery Endpoint.
https://accounts.google.com/.well-known/openid-configuration
- Scroll down the page to locate the OpenID Connect Client ID and OpenID Connect Client Secret.
- Enter the Client ID and Client Secret obtained from Google, and save the page.
- Now you’re able to log in with Google. Simply click on OpenID Connect, and you will be redirected to the Google login page.
- Open an incognito window and test the login process.
- Please select the appropriate account and log in, as shown in the above image.
Conclusion
Integrating Google Login with Liferay transforms the authentication experience by enabling secure, efficient, and user-friendly access through Google credentials. By leveraging OAuth 2.0 and OpenID Connect, Liferay ensures seamless communication with Google as an identity provider. This integration not only enhances usability for end users but also simplifies account management for administrators. Following the outlined steps, you can easily set up and configure Google Login to align with modern security standards and user expectations. Whether for testing or production environments, this feature elevates your platform’s authentication capabilities, making it more dynamic and user-centric.