3

I am using custom visual force page for Community self register and login. I want to add option for register and Login via Gmail and LinkedIn. I created two Authentication Providers and it is working from standard login page. How we can use that providers in our custom visual force page dynamically for any org?

2

If you check the HTML source of the standard login page where Social Login button is present, you can see the following code.

enter image description here

In the JS the useIdp function is defined as below, which takes two arguments and updates the browser URL with the second parameter.

useIdp: function(a, b) {
    if (null !== l) try {
        l.setItem(n(), a)
    } catch (d) {}
    window.location.href = b
},

If you look look carefully at the URL, this nothing but the combination of Auth. Provider Salesforce Configuration URL and your community URL.

Decode this URL and you can see something like this, where ccommunity is my community name.

https://login.salesforce.com/services/auth/sso/00Di0000000inohEAA/MyLinkedIn?community=https://xxxxxxxxxxx.na15.force.com/ccommunity&startURL=/ccommunity/

So in your VF page you can use this same URL in a anchor link to provide user to login via this Social Netowk. Hope this helps.

| improve this answer | |
  • Thank you for giving answer and appreciate your help. Problem is we are using custom Login and registration visual force page with custom UI so how we can get this URL? We can get this SSO Url from Auth. Providers but it would not same for all salesforce org. – Sunil Mar 10 '17 at 9:09
  • You can get this URL from the standard login page. If you want to call the SSO methods directly from VF page then you have to implement the Registration Handler class. Check this link for details help.salesforce.com/… – Saroj Bera Mar 10 '17 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.