Files
2021-02-14 20:59:28 -05:00

60 lines
1.8 KiB
JavaScript

const fs = require('fs');
const jwt = require('jsonwebtoken');
const { http, https } = require('follow-redirects');
// Your Sense Enterprise installation hostname:
const senseHost = 'qseow.jprdonnelly.com';
// Your configured virtual proxy prefix for JWT authentication:
const proxyPrefix = 'jwt';
// The Sense Enterprise-configured user directory for the user you want to identify
// as:
const userDirectory = 'INTERNAL';
// The user to use when creating the session:
const userId = 'sa_api';
// The Sense Enterprise-configured JWT structure. Change the attributes to match
// your configuration:
const token = {
directory: userDirectory,
user: userId,
};
// Path to the private key used for JWT signing:
const privateKeyPath = './fort_private.key';
const key = fs.readFileSync(path.resolve(__dirname, privateKeyPath));
// Sign the token using the RS256 algorithm:
const signedToken = jwt.sign(token, key, { algorithm: 'RS256' });
const options = {
hostname: 'central.browntown.local',
port: 4243,
path: '/qrs/about?xrfkey=abcdefghijklmnop',
method: 'GET',
// agent: 'Windows',
// login: 'INTERNAL\SA_API',
password: '',
headers: {
'X-Qlik-Xrfkey' : 'abcdefghijklmnop',
'X-Qlik-User' : `UserDirectory=${encodeURIComponent('INTERNAL')}; UserId=${encodeURIComponent('sa_api')}`,
'Authorization' : 'Bearer ${signedToken}'}
},
// key: fs.readFileSync("client_key.pem"),
// cert: fs.readFileSync("client.pem"),
// ca: fs.readFileSync("root.pem"),
// rejectUnauthorized: false
};
https.get(options, function(res) {
console.log("Got response: " + res.statusCode);
res.on("data", function(chunk) {
console.log("BODY: " + chunk);
});
}).on('error', function(e) {
con
sole.log("Got error: " + e.message);
});