I'm dealing with quite an unusual issue here, and was wondering if anyone had figured this out.
I'm trying to implement an OAuth flow from one salesforce instance to another (any other). And one of the issues I've run into is if the other instance has the same instance url of the "origin" instance. Everyone's encountered this, when you login to the other instance, you'll be logged out of the original one.
So, to try to get around this, I'm trying to use the frontdoor.jsp (http://docs.releasenotes.salesforce.com/en-us/winter14/release-notes/security_frontdoorjsp.htm) method.
So I'm passing in the UserInfo.getSessionId() in the "state" param, and my pass-through application (hosted on heroku) is forwarding the request back through frontdoor.jsp using the session id passed through.
Now, I was getting a really hard time getting this to work, but what I ended up noticing is that for each context, I was getting different output from the "UserInfo.getSessionId()" call. Not all of them worked when passing through frontdoor.jsp. Here's a summary of the different places I tried it:
- Printing Session Id out to a visualforce page:
- Didn't work when passing this value through frontdoor.jsp
- Print session id in debug log from VF controller
- Same session id as #1, still didn't work for frontdoor.jsp.
- Print session id in developer console:
- Different session id from the VF page, but this one worked on frontdoor.jsp.
- Print session id from a trigger:
- Yet another different session id, but worked with frontdoor.jsp
- Printed from "Execute Anonymous" in Eclipse
- Yet another session Id, but also worked with frontdoor.jsp.
So what I need to know is this: how do I get the "proper" session id that works with frontdoor.jsp when I'm in the context of the Visualforce controller?