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
mshelmanmshelman 

Authentication for callout?

Is there a way to authenticate (Basic authentication) against an external webservice in order to perform Callout from Apex code?
RickyGRickyG
You might find this article on implementing single sign-on from salesforce to provide some direction.

Hope this helps.

- Rick Greenwald
Developer Evangelist
mshelmanmshelman
Perhaps I'm not being clear enough. I'm trying to use the callout feature in Apex code to call a webservice that uses Basic authentication. I've imported the wsdl and generated the Apex code successfully but when I try to use it WebServiceCallout.invoke seems to make the call ok but the response fails, naturally enough, since I haven't logged in to the external webservice. So is there any provision for logging in to an external webservice like this in Apex code when performing the call out?
cheenathcheenath
Currently there is no way to add HTTP headers to the apex web service request.
So you wont be able to set the authorization header on the outgoing request.

This looks like a good feature to have for callouts. Please add this to idea exchange.

Thanks,



mshelmanmshelman
Thank you for the reply.