Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

4111

November 29th, 2017 16:00

REST API Auth with PHP

I'm hoping to see if I can get some guidance on how to auth against appsync with PHP. After reading through the documentation, and tearing apart what I saw from another post in powershell I wrote up a simple script in php- however when I attempt to complete the auth it returns the following message:

starting...

CAS is Unavailable

There was an error trying to complete your request. Please notify your support desk or try again.

done!

The "starting..." and "done!" are just echo'd statically for my sanity. Not sure where to debug as this is within CAS, within Appsync so any help would be great!

The code is as follows:

echo "starting...";
$appsyncServer = "myserver";
$LoginUri = "https://".$appsyncServer.":8444/cas-server/login?TARGET=https://".$appsyncServer.":8445/appsync/";
$ch = curl_init($LoginUri);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, '-');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$curl_response = curl_exec($ch);

echo "
"
;
if ($curl_response === false) {
   $info = curl_getinfo($ch);
   $error = curl_error($ch);
   curl_close($ch);
   echo "
The error:
"
;
   print $error;
   echo "
More details
"
;
   die('error occured during curl exec. Additional info: ' . var_export($info));
}
$login_arr = array("username" => "myuser" , "password" => "mypassword");
$ch = curl_init($LoginUri);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_arr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$curl_response = curl_exec($ch);

curl_close($ch);
print_r($curl_response);
echo "
done!"
;
?>

Thanks in advance!

21 Posts

May 17th, 2018 16:00

I abandoned developing against Appsync- seemed like a great product but support was poor and my patience was little. I ended up interfacing with our arrays directly (mainly VMAX and XtremIO) which both handle authentication much better.

Logging in through the GUI did work, but a browser will follow redirects much more graciously than curl, which is what I think the issue was with auth against appsync / it's sso like service. I was just looking for a little direction but found the array api's have a much better community as well as documentation.

Thanks for chiming in- forgot I posted this. Almost unmarked as correct for the professional services recommendation lol!

No Events found!

Top