Fixing JWT token issue for realtime analytics

This commit is contained in:
Rasika Perera 2016-09-28 11:03:46 +05:30
parent 85a382e16a
commit 6ee958bbe7

View File

@ -32,10 +32,10 @@ function onRequest(context) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier
+ " \", \"type\":\"" + device.type + "\"}]}";
+ "\", \"type\":\"" + device.type + "\"}]}";
var encodedScope = tokenUtil.encode(deviceParam);
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,
"{\"device\": \"" + encodedScope + "\"}");
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default",
{"device": encodedScope});
var token = "";
if (tokenPair) {
token = tokenPair.accessToken;