首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将oauth2令牌传递给mashup filab?

如何将oauth2令牌传递给mashup filab?
EN

Stack Overflow用户
提问于 2015-09-05 17:25:15
回答 1查看 90关注 0票数 2

我遵循了从Identity Manager获取oauth2访问令牌的整个过程(我明白了),我想将它传递给在Filab Mashup上开发但嵌入在我自己的web中的web应用程序。在Mashup应用程序中,我需要获取的oauth令牌来访问Orion上下文代理信息,但我不知道如何传递它。这是我获取令牌的回调URL的代码:

代码语言:javascript
复制
<?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的代码:

代码语言:javascript
复制
<?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应用程序中,我总是有一个匿名连接,因为我不知道如何向它传递令牌。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-09-17 17:50:19

目前无法创建包含凭据的嵌入式WireCloud网址。它看起来很有趣,值得实现,但也有很多工作要做,所以不要指望它能在短时间内实现。

关于从WireCloud访问orion上下文代理,请查看WireCloud's course上提供的"3.2.1.使用Orion上下文代理“一节。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32411479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档