php - Crowd RESTful API cannot connect
I'm trying to use Crowd authentication into my website but I keep getting 401 Application failed to authenticate. I don't know why because I am passing in the application username and password correctly. What I have:
$data = array("value" => "APP_PASS"); $data_string = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://PATH:8095/crowd/rest/usermanagement/2/authentication?username=APP_NAME'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string), 'Accept: application/json' ) ); $output = curl_exec($ch); echo $output; curl_close($ch);
You need to use CURLOPT_HTTPAUTH and CURLOPT_USERPWD for your application user:password. Crowd uses ACLs for the requesting application as well as the user authentication you're requesting.