Oauth 2.0 如何将oauth2令牌传递给MashupFilab?
我已经完成了从Identity Manager(我得到了)获取oauth2访问令牌的整个过程,并希望将其传递给在Filab Mashup上开发但嵌入到我自己的web中的web应用程序。 在我的Mashup应用程序中,我需要获取用于访问Orion上下文代理信息的oauth令牌,但我不知道如何传递它。 这是我获取令牌的回调URL的代码:Oauth 2.0 如何将oauth2令牌传递给MashupFilab?,oauth-2.0,fiware,fiware-wirecloud,Oauth 2.0,Fiware,Fiware Wirecloud,我已经完成了从Identity Manager(我得到了)获取oauth2访问令牌的整个过程,并希望将其传递给在Filab Mashup上开发但嵌入到我自己的web中的web应用程序。 在我的Mashup应用程序中,我需要获取用于访问Orion上下文代理信息的oauth令牌,但我不知道如何传递它。 这是我获取令牌的回调URL的代码: <?php //get the code from url $code = $_GET["code"]; //print_r($code); //appl
<?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');
}
?>
但是在mashup应用程序中,我总是有一个匿名连接,因为我不知道如何传递令牌
提前感谢。目前无法创建包含凭据的嵌入式WireCloud URL。它看起来很有趣,值得实现,但也有很多工作要做,所以不要期望它能在短时间内实现 关于从WireCloud访问orion上下文代理,请参阅FIWARE Academy上提供的“3.2.1.使用orion上下文代理”一节