Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_rest_methods.htm

You can then expose the to the public via Sites:

http://www.wadewegner.com/2013/03/creating-anonymous-rest-apis-with-salesforce-com/

And use the resulting endpoint as your callback...

share|improve this answer
add comment

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.

share|improve this answer
    
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 at 16:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.