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
- Click on Create Project.
- Enter project name and project ID will be automatically inserted. Agree all terms and conditions and click on Create button.
- Go to Credentials under project and select create new client ID.
- 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.
Enter all the details as given below.
- 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.
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.
Now we have to create simple apex class.
Go to setup=>Develop=>Apex Classes=>New.
Select new apex class and write the code given in below screenshot.
Now select Quick Save.
Copy and paste Test-Only Authorization URL in your browser.
A new window will be opened and select Accept button as shown below.
Now a new window will be opened as shown below.
Now provide Single Sign On initialization URL to your organization to login in to salesforce.com account using Google account.