Wednesday, 13 November 2013

Auth. Providers in salesforce.

Login salesforce using Gmail Account.


This is done by the Auth.Providers option in salesforce.

STEP 1:

Create a Google Id field in User Object. and paste the Google User Id into that field Manually.
Google User Id will be there in the below URL.


Create a Apex class which implements Auth.RegistrationHandler


STEP 2:

Create the consumer key and consumer secret from Google API

Goto https://developers.google.com click on API Console ->APIs & auth ->Registered App -> register App


After clicking on register, below screen will appear with client Id and Client Secret.

STEP 3:

Login in to salesforce.

Goto setup->Adminstrators->Security Controls->Auth. Providers.

Click on New.

Choose the providerType as Open Id Connect. below screen will appear.


Enter the client Id and Client Secret in Consumer Key and consumer Secret.
Choose the class, which you have created in step 1 in Registration Handler class.
Choose the User, who is going to execute the registration.

Click on save. After saving client configuration will get generated. From that copy the callback URL and paste it in Redirect URI in Google API Field.

STEP 4:

Enable the Identifier in domain.

Goto setup->Administer->Domain Management->Domains, if you have not created any domain just create the domain now.

Click on the domain name, under Login Page Branding click Edit and enable the Authenticate Service, which you have created in step3.

Click save.

STEP  5:

Logout from Salesforce.My domain name for login page is https://priyamohanraj-dev-ed.my.salesforce.com.below screen will appear when we type this url in browser.

                     

click on Google, it will redirect to below page.


After entering the password, it will redirect to salesforce home page.






No comments:

Post a Comment