Ajax jQuery 401 unauthorised

I’m working with Wowza streaming platform. I would like to use Wowza API recording API. It works well when I type in web browser.
I’m using this link in my Web browser

http://username:password@myurl.com:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording

However, when I used in AJAX called, the prompt pop out which I don’t want that to happen.

$.ajax({
    async : false,
    url : "myurl.com:8086/livestreamrecord?app=live&streamname=myStream&action=startRecording",
    type : 'GET',
    dataType: "jsonp",
    beforeSend: function (xhr) {
        xhr.setRequestHeader('Authorization', "Any " + btoa(user+":"+password));
    },
    }).done(function(response){
            alert("RECORDING..");

});

Though username:password@ append in the link in url ajax wouldn’t work for me. It produced 401 unauthorised error. I don’t want something that prompt out ask for authentication informations but straight direct authorisation without user knowledge.


Source: jquery

Leave a Reply