How to login into Salesforce using Google credentials?

How to login into Salesforce using Google credentials?

To login into Salesforce using Google credentials, use the below steps

1. Go to ““.

2. Click “Create Project”.

3. Enter project name and click “Create”.

4. Go to “Credentials” and click “Create new Client ID”.

5. Select “Web Application”, remove default in “AUTHORIZED JAVASCRIPT ORIGINS” and click “Create Client ID”.

6. Go to “Consent Screen” and enter the Product Name.

7. Go to your Setup –> Administer –> Security Controls –> Auth. Providers and click “New”.

8. Enter the details as below.

In order to get the Consumer Key and Consumer Secret, get Client Id and Client Secret from your Google Project.

9. Copy the Callback URL from Auth. Provider and paste it in Redirec URI.

10. An apex class would have been created. Go to Setup –> Build –> Develop –> Apex Classes and edit the class as mentioned below.

 global class AutocreatedRegHandler1406191530150 implements Auth.RegistrationHandler {
    global User createUser(Id portalId, Auth.UserData data) {
        User u = [SELECT Id FROM User WHERE Email =:];
        return u;
    global void updateUser(Id userId, Id portalId, Auth.UserData data) {

here you can make use of data.FirstName, data.LastName, data.FullName, openid(Google Profile Id) also.

11. Copy the Test-Only authrorization url and paste it in your brower and press enter.

12. Provide Single Sign-On Initialization URL to your organization user to login into Salesforce using Google credentials.

Note: Sometimes, it will get some time to get synchronized. If you get any error in the URL, kindly try after sometime.

Leave a Reply