[SalesForce] SOAP-API authentication

I am trying to implement SOAP-API for Java and find that the authentication is 2 step using the REST and then passing the token in the SOAP header. I also downloaded the example from http://help.exacttarget.com/en/technical_library/web_service_guide/getting_started_developers_and_the_exacttarget_api/connecting_to_the_api_using_java_and_axis2/

In the example I dont find the REST api call but username and password. Which is the correct way to authenticate?

Thanks
–Narasimha

Best Answer

Generally with the SOAP API you have two ways to authenticate a request with Salesforce.

  1. You use the login API call with the username and password to get a SessionID and corresponding Server URL to make the subsequent API calls to. The SessionId should be sent via the SessionHeader. Typically you will need to append the security token to the password unless your IP address has be added to the Org.
  2. You use an alternative means to get a valid Session Id and proceed directly to using the SessionHeader.

There are several alternatives for getting a valid Session Id. OAuth 2.0 is the preferred method if you are requesting credentials from individual users. By selecting the correct flow there is no need for the user to give your app their username and password. Instead you get the resulting access token that can be used for API calls. Generally speaking the access token is interchangeable with the session Id (depending on the requested scopes).

Related Topic