2

I want to access a rest webservice hosted in a salesforce org from another Salesforce org. I am using the web server flow for authentication. When hitting the authorisation URL, I am redirected to a login page and after login, remote authorisation page appears requiring the user to allow/deny access. I somehow want to skip this login and approval when I access the web service next time. Is this possible?

  • There is no way you can skip this .You will need to use User-Agent flow to skip the same .Thanks – Mohith Shrivastava Sep 17 '14 at 12:54
  • Only the login is required again, not the allow/deny access. Make sure to omit the prompt parameter in the initial url you're passing to the auth provider. – Adam Sep 17 '14 at 18:19
1

I'm open to correction here, but I think the appropriate flow to use for this situation is the OAuth 2.0 JWT Bearer Token Flow.

For this flow, you make a HTTP request to https://login.salesforce.com/services/oauth2/token from your Apex code including a username and a Salesforce "Connected App" consumer key. This request is signed using the RSA-SHA256 algorithm and a cert you create in the requesting org. A copy of that signing certificate is also uploaded to the "Connected App" definition in the remote org (whose consumer key is the one in the request) where it is used to verify the request.

This flow relies on the signature information matching and so does not need a web page presenting for the password to be entered. So it can be executed solely through server to server interaction.

Note that I'm working on this right now so have no long term experience with it. Its somewhat awkward to get working.

1

I have achieved something similar using the Web Server flow and getting a Refresh Token - when you use the Auth Code to get the initial oAuth token, you can also get back a refresh token - if you store that somewhere, you can then use that to get new oAuth token using the Refresh Token flow each time you need to make a call into the target Org.

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.