Skip to main content

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
An issue has been identified on Qlik Cloud hub, please visit our Status Update Page for details: GET THE LATEST
cancel
Showing results for 
Search instead for 
Did you mean: 
balaji_m
Partner - Contributor III
Partner - Contributor III

how to generate Xrfkey in qlik sense

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.

https://help.qlik.com/en-US/sense-developer/2.2/Subsystems/RepositoryServiceAPI/Content/RepositorySe...

Thanks in advance.

Regards,

Balaji

7 Replies
Not applicable

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;

balaji_m
Partner - Contributor III
Partner - Contributor III
Author

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

Vincenzo_Esposito

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.

Not applicable

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('');

    },

balaji_m
Partner - Contributor III
Partner - Contributor III
Author

Thanks Vincenzo.

your are correct.

Regards,

Balaji

balaji_m
Partner - Contributor III
Partner - Contributor III
Author

Hello Markus,


Thanks for your help.

Regards,

Balaji

stantrolav
Partner - Creator II
Partner - Creator II

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()