[ https://jira.fiware.org/browse/HELP-9303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fernando Lopez updated HELP-9303:
---------------------------------
HD-Chapter: Apps
Description:
Created question in FIWARE Q/A platform on 05-09-2015 at 11:09
{color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/32411479/how-to-pass-oauth2-token-to-mashup-filab
+Question:+
how to pass oauth2 token to mashup filab?
+Description:+
I have followed the whole process to obtain an oauth2 access token from the Identity Manager (I get it) and I want to pass it to a web application developed on Filab Mashup but embedded in my own web.
In my Mashup application I need get the oauth token for to access Orion Context Broker information but I don't know how to pass it.
This is the code of my callback URL where I obtain the token:
<?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");
?>
And this is the code of 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');
}
?>
But in the mashup application I always have an anonymous connection because I don't know how to pass it the token.
Thanks in advance.
was:
Created question in FIWARE Q/A platform on 05-09-2015 at 11:09
{color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/32411479/how-to-pass-oauth2-token-to-mashup-filab
+Question:+
how to pass oauth2 token to mashup filab?
+Description:+
I have followed the whole process to obtain an oauth2 access token from the Identity Manager (I get it) and I want to pass it to a web application developed on Filab Mashup but embedded in my own web.
In my Mashup application I need get the oauth token for to access Orion Context Broker information but I don't know how to pass it.
This is the code of my callback URL where I obtain the token:
<?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");
?>
And this is the code of 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');
}
?>
But in the mashup application I always have an anonymous connection because I don't know how to pass it the token.
Thanks in advance.
HD-Enabler: Wirecloud
> [fiware-stackoverflow] how to pass oauth2 token to mashup filab?
> ----------------------------------------------------------------
>
> Key: HELP-9303
> URL: https://jira.fiware.org/browse/HELP-9303
> Project: Help-Desk
> Issue Type: Monitor
> Components: FIWARE-TECH-HELP
> Reporter: Backlog Manager
> Assignee: Álvaro Arranz
> Labels: fiware, fiware-wirecloud, oauth-2.0
>
> Created question in FIWARE Q/A platform on 05-09-2015 at 11:09
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/32411479/how-to-pass-oauth2-token-to-mashup-filab
> +Question:+
> how to pass oauth2 token to mashup filab?
> +Description:+
> I have followed the whole process to obtain an oauth2 access token from the Identity Manager (I get it) and I want to pass it to a web application developed on Filab Mashup but embedded in my own web.
> In my Mashup application I need get the oauth token for to access Orion Context Broker information but I don't know how to pass it.
> This is the code of my callback URL where I obtain the token:
> <?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");
> ?>
> And this is the code of 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');
> }
> ?>
> But in the mashup application I always have an anonymous connection because I don't know how to pass it the token.
> Thanks in advance.
--
This message was sent by Atlassian JIRA
(v6.4.1#64016)
You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy Cookies policy