function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
edsheppaedsheppa 

Authenticating Salesforce users from an external service.

My Salesforce app calls out to my own external web service. The documentation says to use the user ID and session ID to authenticate and identify users from an external service. Specifically, you're supposed to put the user and session IDs in the web request then have your service call back through the Force.com API to check that the user has an active session and has been authenticated.

 

I get the idea but there is no example or further explanation. HOW is that done with the API? WHAT API methods are used?

SuperfellSuperfell

most people use getServerTimestamp or getUserInfo calls, i think there's an article on the wiki that describes it in more detail.

edsheppaedsheppa

Thanks, I found that wiki article. It's http://wiki.developerforce.com/index.php/Single_Sign_On_for_Composite_Apps for those who follow.

 

Is there a direct way to get the server URL in Apex without having to pass it from Visualforce? I'm sure there must be or triggers and batch jobs would be sol.

Brian SobyBrian Soby

I would think that the UserInfo class would give that information but it doesn't look like it.  The only method that I can think of offhand would be to have a VF page that contains only the API server merge field (no headers, stylesheets, etc).  You could then create a page reference for that page and access its rendered content through Apex.  It's really, really ugly but I think it should work.

 

Thanks

-Brian Soby