I'm using this php script to access to access to /oauth2/authorize openam's endpoint :
<?php
//debug
error_reporting(E_ALL);
ini_set('display_errors', 1);
//debug end
function get_web_page($url)
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => true, // return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$header = curl_getinfo($ch);
curl_close( $ch );
//print($header[0]);
echo $content;
//var_dump($content);
return $header;
}
$thisurl = "http://openam.example.com:8080/openam/oauth2/authorize?realm=/openLDAP&client_id=agent2&redirect_uri=http://openam.test.com:8080/openam&response_type=code&scope=profile";`
$myUrlInfo = get_web_page($thisurl);
//echo $myUrlInfo["url"];
?>
And I'm getting blank webpage but I can see in the subtitle "ForgeRock Access..." and I think the agent2 authentication was successful because when I change "agent2" to "agent1" I have this error in debug folder : ERROR: Unable to get Client Registration for client_Id = agent1
It's why I conclude that I was able to connect to the endpoint but I don't understand why I'm not redirected to user authentication webpage.
I already tried the same script and change the url to "https://www.google.fr/" and in that case I'm redirected to google.
Thank you in advance for your help.
Output after adding var_dump( $myUrlInfo ); :
array(26) { ["url"]=> string(35) "http://openam.test.com:8080/openam/" ["content_type"]=> string(9) "text/html" ["http_code"]=> int(200) ["header_size"]=> int(391) ["request_size"]=> int(498) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(1) ["total_time"]=> float(0.007415) ["namelookup_time"]=> float(1.4E-5) ["connect_time"]=> float(1.7E-5) ["pretransfer_time"]=> float(9.4E-5) ["size_upload"]=> float(0) ["size_download"]=> float(1626) ["speed_download"]=> float(219285) ["speed_upload"]=> float(0) ["download_content_length"]=> float(1626) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.001315) ["redirect_time"]=> float(0.006082) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(12) "XXX.XX.XX.XX" ["certinfo"]=> array(0) { } ["primary_port"]=> int(xx) ["local_ip"]=> string(12) "XX.XX.XX.XX" ["local_port"]=> int(xxx) }
To be redirected to the openam's logging webpage I needed to use the header method.
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="style.css"/>
<title>UMA forgerock test appli</title>
</head>
<body>
<h2 id="generateCode">Retrieve authorization code</h2>
<form method="post" action="">
<input id="bouton" type="submit" name="generateCode" value="generateCode">
</form>
<?php
if(isset($_POST['generateCode'])) {
$url = "http://openam.test.com:8080/openam/oauth2/authorize";
$params = array(
"response_type" => "code",
"client_id" => xxx,
"realm" => "/openLDAP",
"redirect_uri" => 'http://uma.test.com/umaTestAppli',
"scope" => "profile"
);
$request_to = $url . '?' . http_build_query($params);
header("Location: " . $request_to);
}
?>
</body>
</html>