Chrome.webRequest.onAuthRequired Listener

I am trying to intercept proxy authorization inside the chrome extension. After answering this question: Authorizing a domain in the Chrome extension and reading documents here my code is as follows:

chrome.webRequest.onAuthRequired.addListener( function(details, callbackFn) { console.log("onAuthRequired!", details, callbackFn); //callback({ // authCredentials: {username: "1", password: "__TestUse"} //}); }, {urls: ["<all_urls>"]} ); 

The problem is that callbackFn is undefined , but must be a function.

Someone have ideas why callbackFn is undefined. When I read documents, I do it right.

+6
source share
1 answer

The code works, I just forgot to add another parameter ['asyncBlocking'] . This code works very well:

 chrome.webRequest.onAuthRequired.addListener( function(details, callbackFn) { console.log("onAuthRequired!", details, callbackFn); callbackFn({ authCredentials: {username: "1", password: "__TestUser"} }); }, {urls: ["<all_urls>"]}, ['asyncBlocking'] ); 
+9
source

Source: https://habr.com/ru/post/945277/


All Articles