We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

set authorization header from puzzles

Home Forums General Questions set authorization header from puzzles

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #56143
    David Bujeda
    Customer

    Hello,

    I would like to know if it is possible to set the authorization header from the puzzles when using send data. As per now, I’m saving the puzzle and hardcoding in the visual_logic.js after that.

    // sendData puzzle
    function sendData(data, url, callback) {
    var req = new XMLHttpRequest();

    req.onreadystatechange = function() {
    if (req.readyState == 4 && req.status == 200) {
    if (req.getResponseHeader(‘Content-Type’).indexOf(‘application/json’) > -1)
    _pGlob.loadedFile = JSON.parse(req.responseText);
    else
    _pGlob.loadedFile = req.responseText;

    callback();
    }
    };

    req.open(‘POST’, url, true);

    if (typeof data == ‘string’) {
    req.setRequestHeader(‘Content-type’, ‘text/plain’);
    } else {
    // serialize to json
    req.setRequestHeader(‘Content-type’, ‘application/json’);
    data = JSON.stringify(data);
    }
    req.setRequestHeader(‘Authorization’, ‘xxxxxxx’);
    req.send(data);
    }

    Attachments:
    You must be logged in to view attached files.
    #56149

    Hi,

    you could possibly employ the exec script puzzle for adding custom code. This would save you from repeatedly editing of freshly generated visual_logic.js.

    https://www.soft8soft.com/docs/manual/en/puzzles/Advanced.html#exec_script

    Chief 3D Verger | LinkedIn | Twitter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.