I'm trying to setup a custom force.com site VF page that will allow standard user logins to multiple orgs on different domains.

My site lives on an na12 org, and the login for that site works correctly. I'm using the ajax toolkit to submit the UN/PW+token to get the session ID then redirecting to the frontDoor.jsp page.

I'm basically following this example: https://github.com/BPeddle/SFDC.Custom.Login/blob/master/custom_login.page

My issue is I'm getting an invalid login error when trying other logins to different orgs. Any suggestions? I've tried adding the force.com site URL to remote site settings in the other orgs, adding its IP to the whitelist IP list, neither seem to make a difference.

2 Answers 2


I think the problem is that the login request should (in general) go to login.salesforce.com, rather than a specific instance. Since you can't open a connection to login.salesforce.com, due to JavaScript's same origin policy, you might consider passing the username and password to the page controller, doing the login from there, then redirecting to frontdoor.jsp via the returned PageReference.

  • Thanks, yeah I just tested doing the SOAP call from Apex to get the session ID and endpoint and building the redirect from those, that seems to work.
    – Phil B
    Commented Jan 27, 2014 at 3:42

I think from outside URLs you need to make use of SAML or OAuth 2.0 that Salesforce already provides for making Single Sign-on functionality as Connected Applications.

  • The Ajax toolkit is just utilizing the SOAP API. Why wouldn't this be available from outside URLs?
    – Phil B
    Commented Jan 24, 2014 at 20:04
  • Sorry for replying late but it seems it might help you logging-in from outside using URL Redirect: test.salesforce.com.sandbox?loginType=2&[email protected]&…. Where test.salesforce.com is the type of Sandbox Account, un is Username and pw is password of your account. Let me know if it still can be considered.
    – sanchit
    Commented Jan 29, 2014 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .