I am attempting to develop an Apex class/method that will callout to an external application via a Rest interface. This external application requires a callback URL be passed to it in the call, and then adds special access tokens to the callback url during the redirect. My question is this, what Callback URL can I pass so I can get these tokens back in salesforce to use with my application for the actual interactions with the external system (after the authentication has occurred). Does anyone have suggestions on how to accomplish this?

My current HTTPResponse only comes back with a Status 200 (OK), as the callbackURL is what is supposed to pick up the flow (with the additional tokens).

Thanks in advance! Jim


You can call out from APEX using HTTP, but you can also setup a custom REST endpoint:


You can then expose the to the public via Sites:


And use the resulting endpoint as your callback...


your callback URL is the landing page once the http callout returning the response. Your callback URL should be able to handle the session or token and would be able to reissue for subsequent requests. It should be SSL. The callback does not necessarily to be a force.com site. it could be any website developed from any language. If you tested your REST classes in POSTMAN you cannot simulate this scenario. Otherwise, for instance if you have a website developed with PHP you can issue a request from that and can see the response posted to the callback URL.

Please follow the notes in this article with examples, it gives you a better understanding.

http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php http://wiki.developerforce.com/page/REST_API

Try to setup a force.com site and start experimenting with it. Because that saves you from getting an SSL or installing an SSL in a PHP unless if you do not want for real time development.

  • Actually, my scenario is different than what you describe. What I am trying to do is invoke a callout (via a trigger) from Salesforce to an external system that has a published Rest interface. That external system requires that I supply a callback URL that it will redirect to, and add the authorization tokens to the query parameters. The problem is, my app is completely contained inside my apex class, I need to authorize, retrieve the token, and then execute an authorized callout to perform my desired function in the external system, all from my Apex class, there is no other site to access. – JimRae Mar 25 '14 at 16:35

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.