Highlighted
2 Bronze

REST API Auth with PHP

Jump to solution

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:

<?php
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 "<br />";
if ($curl_response === false) {
   $info = curl_getinfo($ch);
   $error = curl_error($ch);
   curl_close($ch);
   echo "<br /> The error: <br />";
   print $error;
   echo "<br /> More details <br />";
   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 "<br />done!";
?>

Thanks in advance!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted

Re: REST API Auth with PHP

Jump to solution

Are you having any issues logging in to AppSync through the GUI? The error, which comes from within AppSync as you have said, suggests that a standard login through the GUI may not work either. If there is an issue here, I recommend opening a Service Request.

If the issue is with the script only, I recommend contacting Professional Services.

View solution in original post

0 Kudos
2 Replies
Highlighted

Re: REST API Auth with PHP

Jump to solution

Are you having any issues logging in to AppSync through the GUI? The error, which comes from within AppSync as you have said, suggests that a standard login through the GUI may not work either. If there is an issue here, I recommend opening a Service Request.

If the issue is with the script only, I recommend contacting Professional Services.

View solution in original post

0 Kudos
Highlighted
2 Bronze

Re: REST API Auth with PHP

Jump to solution

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!