0

I use the oauth flow to allow users to authorize my Salesforce app to access the API on their behalf.

Depending on input in my app, I either prompt them with https://login.salesforce.com/services/oauth2/authorize or https://test.salesforce.com/services/oauth2/authorize (notice "login" vs. "test").

But once they authenticate and are redirected back to my app, with a code parameters attached via URL params, I no longer know whether they were on sandbox or not.

Is there a way to persist that info, from the point of going to the Salesforce authorize url, to the point of returning to the page with the code? Either through the redirect uri (like, by adding query parameters onto it) or other?

Or perhaps seeing which URL the redirect just came from? Because that's the info I need. I don't need arbitrary parameters saved. I need specifically whether the authorization was sandbox or regular.

0

You surely shouldn't need to know URL again?

Your app knows which endpoint it is authenticating against right?

Given that is the case, your app is what will receive the OAuth response.

I don't see how your app wouldn't still know what it just called out to, as the response is returned to the caller.

I might be missing something, so can you please explain which of the OAuth flows you are using?

  • Web-Server
  • User-Agent
  • etc?
  • I did end up using the application to remember which it is authenticating against. I used Simple Storage. The original difficulty is that the oAuth flow (web-server) leaves your site to go to Salesforce's login form, then returns, so much of your application's state is lost. I wanted deal with that by passing a parameter in the redirect_uri as is pretty standard, but instead used the alternative of Session Storage. – tscizzle Jul 28 '17 at 18:43
0

OAuth flows support an optional state parameter, which can be used in this situation:

state: Specifies any additional URL-encoded state data to be returned in the callback URL after approval.

See more in Developer Guide and Help pages.

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.