Here is my case study:

  • We are developing a mobile app.

  • The mobile app interacts with two salesforce orgs i.e.

    1. Metadata org : Having all the customer metadata required by mobile app for each customer.
    2. Real customer salesforce org: This org is real customer org they use for their CRM or other use.

One way to use both orgs with mobile app is to Oauth with both of them and store the tokens. But that would require us making the customer do OAuth requests two times.

One way I see, is to use Salesforce Auth provider and make user click on the Auth Provider SSO URL(iPhone WebView can be used) to create user in Metadata org. But we don't have a way to again get the auth token for the newly created user.

Whats best way to deal with this, that requires minimal OAuth flows ?

  • 2
    I would handle the Metadata org credentials as my app settings as that won't change very often. If you are using the mobile sdk, you should use the oAuth webview to authenticate against hte real customer org and once that's done, authenticate with your metadata org using an AJAX request. This will ensure that your users do not need to authenticate against metadata every time as it doesn't really make sense. So, users will essentially need to auth only once in the login flow (only if they logout from the real customer org). Jan 9, 2013 at 11:40
  • This is good detail +Gaurav, thanks I will try that ! Jan 9, 2013 at 15:42

1 Answer 1


Use the SessionHeader field on the sforceservice to instantiate the metadataservice object. This way, the metadata api can piggy back off of the already authenticated sforceservice api object.

  • You're describing how to use two APIs in the same org - question is how to use APIs from two different orgs.
    – metadaddy
    Mar 11, 2013 at 15:26

You must log in to answer this question.

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