I am building a web portal for the SalesForce Service Cloud using the REST API (PHP/WordPress Project).

I need Service Cloud users to be able to login to the site through the API without being forwarded to a SalesForce hosted page. I have been able to login full SFDC users, but I cannot find anything in the REST documentation for logging in Service Cloud users.

Using SOAP to accomplish this task in previous projects, I just had to set the LoginScopeHeader to pass the customer portal ID and the organization ID when logging in a service cloud user. However I cannot find a method for doing this in REST.

If anyone has run into this in REST, and knows wether it is possible or not, and if so how to do it; I would really appreciate the help.

Here is the code I am currently using to login a full SFDC user:


$loginurl = "https://test.salesforce.com/services/oauth2/token";
$params = "grant_type=password"
    . "&client_id=" . CLIENT_ID
    . "&client_secret=" . CLIENT_SECRET
    . "&username=" . USERNAME
    . "&password=" . PASSWORD;

$curl = curl_init($loginurl);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 ) {
    die("Error: call to URL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));


$response = json_decode($json_response, true);
$access_token = $response['access_token'];
$instance_url = $response['instance_url'];
  • 1
    You could take the cheap way out and call the Partner API to complete the login and get the sessionId and instanceURL. Then use these values for the access token and instance url in the REST api. Commented Jul 3, 2014 at 2:22
  • Yea I have thought of this as a workaround, and it seems like it is a legit option that would work. Although I sorta feel like if I have to use SOAP here, I might as well SOAP the whole thing. I am still hoping there is a RESTful way to do this.
    – Matt Keys
    Commented Jul 3, 2014 at 17:20


You must log in to answer this question.

Browse other questions tagged .