2

プロセス全体に従って、Identity Manager から oauth2 アクセス トークンを取得し (取得しました)、それを Filab Mashup で開発されたが自分の Web に埋め込まれた Web アプリケーションに渡したいと考えています。私の Mashup アプリケーションでは、Orion Context Broker 情報にアクセスするための oauth トークンを取得する必要がありますが、それを渡す方法がわかりません。これは、トークンを取得するコールバック URL のコードです。

<?php
//get the code from url
$code = $_GET["code"];

//print_r($code);

//application specific declarations
$domain = "www.talkysync.com";
$clientId = "my_client_ID";
$clientSecret = "my_client_secret";
//access token url
$url = 'https://account.lab.fiware.org/oauth2/token';

//payload params for the request token
$payload = 'grant_type=authorization_code&code='. $code .'&redirect_uri=http%3A%2F%2Fwww.talkysync.com%2Ffiware_login%2Fcallback.php';

//base64(client_id:client_secret)
$cadena = $clientId . ":" .$clientSecret;
$base = base64_encode($cadena);

//extra header for the request
$header = array("Content-Type: application/x-www-form-urlencoded", "Authorization: Basic ". $base);

//actual request implementation
$ch = curl_init($url);

curl_close($ch);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
;
//get the access token from the json response

$jsonData = json_decode($output,true);
$access_token = $jsonData["access_token"];

//start a session and set the access token to it
session_start();
$_SESSION["X-Auth-Token"] = $access_token;
$_SESSION["code"] = $code;

header("Location: fiware.php");
?>

そして、これは fiware.php のコードです:

<?php
session_start();
if(!isset($_SESSION["X-Auth-Token"])){  
    header('Location: login.php');
}else{
    header('Location: https://mashup.lab.fiware.org/ertonio/Talkykar?mode=embedded');
}
?>

しかし、マッシュアップ アプリケーションでは、トークンを渡す方法がわからないため、常に匿名接続を使用します。

前もって感謝します。

4

1 に答える 1

1

現在、クレデンシャルを含む組み込みの WireCloud URL を作成することはできません。興味深いので実装する価値があるように見えますが、多くの作業が必要なようにも思われるため、短期間で実装されるとは思わないでください。

WireCloud から orion Context Broker にアクセスする方法については、FIWARE Academy で利用できるWireCloud のコースのセクション「3.2.1. Orion Context Broker の使用」を参照してください。

于 2015-09-17T09:50:18.500 に答える