Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying to access REST API using Postman so i have to pass Xrfkey key.I dont' know how to get this key.Please refer the link for your reference.
awaiting for your help.
Thanks in advance.
Regards,
Balaji
The xrfkey needs to be 16 characters long and should contain normal characters :
var X-Qlik-Xrfkey = '0MwkYLXpxHrbkKGu'
and depending on what api call you're making example : 'session/' + profile.SessionId + '?xrfkey=' + xrfkey;
Hello Markus,
Thanks for your reply.
shall we give static Xrfkey or it should be generated one from Qlik Sense.
If it is generated one then please let me know the procedure to generate the Xrfkey.
Can you please clarify this.
Regards,
Balaji
Hi Balaji,
You can put any 16 characters string as you like. What is really important is to put exactly the same string I both parameters. X-Qlik-Xrfkay in the request header and Xfrkay in the query string.
You want to do this for a "protection" against those who can contact the server pretending to be you.
You can use a static string which full fill the requirement, which are already stated above or create a function to generate a new key within each request (no neccessary)
But this is a string which you add to your request.
Also as stated in the docs, the xrfkey param has to match the x-Qlik-Xrfkey..
example generator from qlik-auth node module::
function generateXrfkey() {
size = 16;
chars = 'abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789';
var rnd = crypto.randomBytes(size), value = new Array(size), len = chars.length;
for (var i = 0; i < size; i++) {
value = chars[rnd % len]
};
return value.join('');
},
Thanks Vincenzo.
your are correct.
Regards,
Balaji
Hello Markus,
Thanks for your help.
Regards,
Balaji
function without any additional modules.
function generateXrfkey() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_length = 16;
var value = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
value += chars.substring(rnum,rnum+1);
}
return value;
};
xrfkey = generateXrfkey()