How to add Magento 2 Google Login to your website?

Many e-commerce businesses require an affordable, straightforward solution to access control for employees. Requiring complex passwords that are difficult to remember is impractical. This is why many businesses are opting to utilize Google’s secure authorization to control access to the backend of their sites. Setting this feature up allows your employees to use their G-Suite account – the same account they already use for all of Google’s services – to access your site. This saves you and your employees time by reducing the need for manual access and enabling easy mobile access.

Here’s how to set up this useful feature on your Magento 2 site.

Step 1: Set Up Google Account

We need to start with your Google Account’s settings. Navigate to the Google Admin Console Home Page and then click on “Apps.” Next, click on “SAML apps.

Click the “+” icon to enable SSO for a SAML application. This will open a new screen that will give you the option to “Setup My Own Custom App.” Select that option.

Once more, a new window will open, and you will then see the SSO URL and the Entity ID for your app. You should also see your certificate from Google. Copy and download these items for use in the next step.

Step 2: Magento Google Connect

In order to achieve the full Magento login with a Google connection, you will now need to download and install an extension to your Magento 2 store. One of the best options for this is to utilize Amasty’s Google Account Login extension. It’s simple to use, powerful, and quick to get up and running. You could write your own code for this extension, but that could take hours to build, run, and finalize and require a great deal of expertise. The more practical solution, and the one adopted by most Magento users, is to utilize an extension, so that is the path we will follow in this guide.

Once you have downloaded the Google Account Login extension and installed it in your store, log in to your Magento 2 Admin panel. First, run the following command in the SSH: “composer require onelogin/php-saml.” This is a pre-requisite for this extension.

Navigate to Stores, then click on “Configuration.” Next, click on “Google Account Login” under “Amasty.”

Here, set “Enable Admin Login with Google” to “Yes” using the dropdown menu. Under the fields “Valid ACS URL” and “Valid Entity ID,” you will notice that they have been filled in automatically. For the final three fields, use the material provided to you in the last step by Google.

Step 3: Further Google Configurations

Return to Google Cloud and progress through the wizard to set up your custom app. You will now be able to name your application, describe it, and choose an image to be used as a logo for your business. Note the requirement of 256x25x pixels in size. Click “Next.

Next up, we have the Service Provider Details window. You can fill in these fields by copying and pasting the pre-filled fields from your Magento 2 Google Account settings in the previous step. The rest of the settings are optional. Click “Next.”

The final step is called Attribute Mapping and is step 5 of the wizard. Here, you can choose the attributes you want using the available user profile fields. Be sure to have a separate admin user email address set up in addition to your employee email address mappings. Otherwise, all your employees will be automatically logged into your company Google account.

Finally, click “Finish.”

Step 4: Activate The SAML App

The final step is to navigate back to the Google Admin Console home page and go to “Apps” and then “SAML Apps.” You should then see your new login SAML app. Click on it. This will open the app’s main screen.

Click “Edit Service,” and then set the setting to “On” for everyone in your organization to activate the plugin. You could also select specific departments to use Google Login by using the Organizational Units sidebar menu on the left side of the screen.

Finally, “Save” your configuration.


In case you would like to reduce manuall efforts in setting up Google account login, check out the Google Account Login from Amasty 

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.