mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
Added readme and corrected code
This commit is contained in:
7
api-samples/webRequest/http-auth/http-auth.txt
Normal file
7
api-samples/webRequest/http-auth/http-auth.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# HTTP onAuthRequired
|
||||
|
||||
This sample demonstrates the use of the webRequest.onAuthRequired listener to detect an authentication request and log the user into designated site.
|
||||
|
||||
## Overview
|
||||
|
||||
When an authentication check is detected, a check is made to confirm that the request has come from the correct source. Account credentials are then provided for the response via an auth handler.
|
||||
@@ -18,8 +18,8 @@ chrome.webRequest.onAuthRequired.addListener(
|
||||
console.log('An authorization request has been detected');
|
||||
if (details.url == 'https://jigsaw.w3.org/HTTP/Basic/') {
|
||||
// Creating some credentials
|
||||
const username = 'username';
|
||||
const password = 'password';
|
||||
const username = 'guest';
|
||||
const password = 'guest';
|
||||
// Creating an auth handler to use the credentials
|
||||
const authCredentials = {
|
||||
authCredentials: {
|
||||
@@ -31,5 +31,5 @@ chrome.webRequest.onAuthRequired.addListener(
|
||||
}
|
||||
},
|
||||
{ urls: ['https://jigsaw.w3.org/HTTP/Basic/'] },
|
||||
['blocking']
|
||||
['asyncBlocking']
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user