How to Create an Authentication Provider



You choose which auth providers can access your Salesforce org from Setup. With a few clicks, you can add the option to log in with one or more social accounts. Here’s how to set up Facebook as an auth provider.
  1. From Setup, enter Auth in the Quick Find box, then select Auth. Providers.
  2. Click New, then select Facebook for the provider type.
  3. Name the auth provider Facebook.
  4. For Registration Handler, click Automatically create a registration handler template.
  5. For Execute Registration As, choose yourself. Heads up: This step is essential and often gets overlooked.

    In production, you don’t choose yourself. You create a service account instead to avoid problems in the future. If you use yourself and leave the company, the process starts to fail when your Salesforce account is disabled.

  6. For Icon URL, click Choose one of our sample icons, select an icon, copy the URL, and paste it in Icon URL.
  7. Leave the other fields empty. Salesforce supplies the values, including the consumer key and consumer secret, when you use the Salesforce out-of-the-box providers (Facebook, Google, and so on).
  8. Click Save.

After defining the auth provider, Salesforce generates several URLs. Use the Test-Only Initialization URL to test your connection with the social network.

  1. From the auth provider detail page, under Salesforce Configuration, copy the URL displayed in Test-Only Initialization URL.
  2. Paste the URL into a browser.

    If it works, you get the Facebook login page.

  3. Log in to the Facebook page.

  4. When prompted, authorize your app.

    You’re redirected to Salesforce, where you see the XML information that Facebook sent us.

    This XML information is useful for debugging and adding more functionality to your auth provider. Here we see that the Facebook user name, his org ID, link to his Facebook account, and email address.

Log In with Facebook

Now that you’ve created a Facebook authentication provider, let’s return to the Login & Registration page and add Facebook as a login option.
  1. From Setup, enter All Communities in the Quick Find box, select All Communities, then click Workspaces next to customers.
  2. Select Administration, then Login & Registration and you see that Facebook is now an option.

 

To confirm your change, return to your private (incognito) browser and reload the login (customers Communities URL)page. Check that the Facebook icon appears on the login page.

This blog is very useful to learn about the Authentication Provider Setup.