Details
-
Type: Monitor
-
Status: Closed
-
Priority: Major
-
Resolution: Done
-
Affects Version/s: None
-
Fix Version/s: 2021
-
Component/s: FIWARE-TECH-HELP
-
Labels:
-
HD-Chapter:Apps
-
HD-Enabler:Wirecloud
Description
Created question in FIWARE Q/A platform on 05-09-2015 at 11:09
Please, ANSWER this question AT http://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.
Activity
Transition | Time In Source Status | Execution Times | Last Executer | Last Execution Date | |||||
---|---|---|---|---|---|---|---|---|---|
|
1s | 1 | Backlog Manager | 23/Sep/15 10:04 AM | |||||
|
5d 26m | 1 | Backlog Manager | 28/Sep/15 10:31 AM | |||||
|
15d 5h 35m | 1 | Manuel Escriche | 13/Oct/15 4:07 PM |
Fix Version/s | 2021 [ 12600 ] |
HD-Enabler | Wirecloud [ 10857 ] | |
HD-Chapter | Apps [ 10836 ] |
Summary | FIWARE.Question.Lab.Apps.ApplicationMashup.EmbedDashboardUsingCredentials | FIWARE.Question.Tech.Apps.ApplicationMashup.EmbedDashboardUsingCredentials |
Summary | FIWARE.Question.Lab.Apps.ApplicationMashup.UseOAuth2TokenFromWidget | FIWARE.Question.Lab.Apps.ApplicationMashup.EmbedDashboardUsingCredentials |
Summary | FIWARE.Question.Lab.how to pass oauth2 token to mashup filab? | FIWARE.Question.Lab.Apps.ApplicationMashup.UseOAuth2TokenFromWidget |
Assignee | Álvaro Arranz [ aarranz ] |
Resolution | Done [ 10000 ] | |
Status | Answered [ 10104 ] | Closed [ 6 ] |
Status | In Progress [ 3 ] | Answered [ 10104 ] |
Component/s | FIWARE-TECH-HELP [ 10278 ] |
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | In Progress [ 3 ] |
2015-09-28 10:30|UPDATED status: transition Answered| # answers= 1, accepted answer= True