Salesforce Login From Google Account

In our previous Salesforce Tutorial we have learned about Salesforce  password policies. In this Salesforce Training Tutorial we are going to learn about how to login in to salesforce.com account from Google account. In this Salesforce Training we get clear idea about how to connect salesforce and Google account through open ID account.

Fist we have to create a new project for salesforce login in console.developer.google.com. In Google we are given various Keys and Client ID’s. By using those client we make some configurations in Auth providers for salesforce login using Google Account. Follow the steps carefully

Salesforce.com Login From Google Account

salesforce login through google

  • Click on Create Project.

salesforce login through google0

  • Enter project name and project ID will be automatically inserted. Agree all terms and conditions and click on Create button.

salesforce login through google1

  • Go to Credentials under project and select create new client ID.

salesforce login through google2

  • Select application type as Web application and clear all authorized URL and click on Create Client ID.

Now go to Administer=>Security Controls=>Auth.Providers.

salesforce login through google3

Select  New.

salesforce login through google4

salesforce login through google5

Enter all the details as given below.

salesforce login through google6

  • Select Provider type as Open ID Account.
  • Enter name as Google login.
  • Give URL Suffix as Google Login.
  • Enter consumer and Consumer secret key. These keys are available when creating client ID’s.
  • Enter authorize endpoint URL as https://accounts.google.com/o/oauth2/auth.
  • Enter token endpoint URL as https://accounts.google.com/o/oauth2/token
  • Enter user info endpoint URL as https://www.googleapis.com/oauth2/V3/userinfo.
  • Select execute registration handler template.
  • Finally click on SAVE button.

salesforce login through google7

Copy and paste Test-only initialization URL and Callback URL these two URL’s are used in next steps.

Now Edit Client Settings in Google account and paste Callback URL in Authorized redirect URL section and select update.

salesforce login through google8

Now we have to create simple apex class.

Go to setup=>Develop=>Apex Classes=>New.

salesforce login through google9

Select new apex class and write the code given in below screenshot.

salesforce login through google10

Now select Quick Save.

Copy and paste Test-Only Authorization URL in your browser.

salesforce login through google100

A new window will be opened and select Accept button as shown below.

salesforce login through google11

Now a new window will be opened as shown below.

salesforce login through google12

Now provide Single Sign On initialization URL to your organization to login in to salesforce.com account using Google account.