function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JPClark3JPClark3 

Any Sample code for connecting two ORGs with OAUTH2 without re-logging in

I'm attempting to authenticate between two ORGs using OAuth2. 

It seems to be working OK, except after I authenticate the remote ORG, I have to log-back-in to the client ORG for the callback to record the access token.

 

I've attempted adding the existing session ID onto the call back URI, but it gets lost.

 

string sessionId = UserInfo.getSessionId();
string OpenCallback = service.Redirect_URI__c+'?access_token=' + sessionId;
callbackUrl = EncodingUtil.urlEncode(OpenCallback, 'UTF-8');

 Has anyone else been able to authenticate between ORGs this way?

 

Thanks