允许php应用程序访问/ oauth2 / authorize端点OPENAM

时间:2017-09-07 10:15:11

标签: php oauth-2.0 openam

我正在使用这个php脚本访问/ oauth2 /授权openam的端点:

<?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"];
?>

我得到空白网页,但我可以在副标题“ForgeRock Access ...”中看到,我认为agent2身份验证成功,因为当我将“agent2”更改为“agent1”时,我在调试文件夹中出现此错误:ERROR: Unable to get Client Registration for client_Id = agent1 这就是为什么我得出结论我能够连接到端点,但我不明白为什么我没有重定向到用户身份验证网页。 我已经尝试了相同的脚本并将网址更改为“https://www.google.fr/”,在这种情况下,我将重定向到Google。 预先感谢您的帮助。 添加var_dump($ myUrlInfo)后的输出; :

array(26){[“url”] =&gt; string(35)“http://openam.test.com:8080/openam/”[“content_type”] =&gt; string(9)“text / html”[“http_code”] =&gt; int(200)[“header_size”] =&gt; int(391)[“request_size”] =&gt; int(498)[“filetime”] =&gt; int(-1)[“ssl_verify_result”] =&gt; int(0)[“redirect_count”] =&gt; int(1)[“total_time”] =&gt; float(0.007415)[“namelookup_time”] =&gt; float(1.4E-5)[“connect_time”] =&gt; float(1.7E-5)[“pretransfer_time”] =&gt; float(9.4E-5)[“size_upload”] =&gt; float(0)[“size_download”] =&gt; float(1626)[“speed_download”] =&gt; float(219285)[“speed_upload”] =&gt; float(0)[“download_content_length”] =&gt; float(1626)[“upload_content_length”] =&gt; float(0)[“starttransfer_time”] =&gt; float(0.001315)[“redirect_time”] =&gt; float(0.006082)[“redirect_url”] =&gt; string(0)“”[“primary_ip”] =&gt; string(12)“XXX.XX.XX.XX”[“certinfo”] =&gt; array(0){} [“primary_port”] =&gt; int(xx)[“local_ip”] =&gt; string(12)“XX.XX.XX.XX”[“local_port”] =&gt; int(xxx)}

1 个答案:

答案 0 :(得分:0)

要重定向到openam的日志记录网页,我需要使用header方法。

let name : array = array[0]["title"]