title: Fill the username and password in NTLM popup in chrome using native messaging
body: <p>Site: <a href="https://httpbin.org/basic-auth/user/passwd" rel="nofollow noreferrer">https://httpbin.org/basic-auth/user/passwd</a></p>
  <p>When we visit the site, the <code>onAuthRequired</code> method is triggered in <code>background.js</code>.
  As per the mdn docs <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onAuthRequired" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onAuthRequired</a> we can pass the username and password field using the <code>extraInfoSpec</code> as <code>blocking</code>.</p>
  <p>Tested Approach:
  <code>background.js</code></p>
  <pre><code>const myCredentials = {
    username: &quot;me@company.com&quot;,
    password: &quot;zDR$ERHGDFy&quot;
  }
  function provideCredentialsSync(requestDetails) {
    // If we have seen this request before, then
    // assume our credentials were bad, and give up.
    if (pendingRequests.indexOf(requestDetails.requestId) != -1) {
      console.log(`bad credentials for: ${requestDetails.requestId}`);
      return { cancel: true };
    }
    pendingRequests.push(requestDetails.requestId);
    console.log(`providing credentials for: ${requestDetails.requestId}`);
    return { authCredentials: myCredentials };
  }
  
  browser.webRequest.onAuthRequired.addListener(
    provideCredentialsSync,
    { urls: [target] },
    [&quot;blocking&quot;]
  );
  
  </code></pre>
  <p>For reference see github code: <a href="https://github.com/mdn/webextensions-examples/tree/master/stored-credentials" rel="nofollow noreferrer">https://github.com/mdn/webextensions-examples/tree/master/stored-credentials</a></p>
  <p>As per the above approach, it tries to authenticate using the given credentials.
  And if correct credentials then will redirect to respective page.</p>
  <p>Questions</p>
  <ol>
  <li>How to only fill the credentials and not hitting the request? The user will click on the <code>Sign In</code> button manually.</li>
  <li>How to fill or pass the credentials using the Native Host? The native host will send the credentials and that credentials will be passed to the above approach for authentication.</li>
  </ol>