title: chrome-extension: How to detect and retrieve url from tab when redirect happens?
body: <p>Just started on chrome - extension development. I'm trying to retrieve the url from a newly created tab but my expected url comes from the server as response with 302 status code and browser redirects to it. I tried with chrome.tabs.onUpdated.addListener() but its not detecting the URL with 302. I searched in chrome.tabs API and i don't see any events for redirect. What is the best way to detect if any redirection is happening in the tab and get the url from that object?</p>
  
  <p>My use case is, when user clicks on one button, it opens a new tab with a specific url and since this url is SSO protected which will go through SSO dance and finally goes to target page.During SSO dance there are 3 redirects happening before serving the target page and i'm trying to detect and retrieve one of the url in the redirect process.</p>
  
  <p>P.S: This is my first question and i'm excited to be part of this community. Thanks in advance.</p>
  
  <p>Update1: I tried with chrome.webRequest.onBeforeRedirect.addListener</p>
  
  <p><strong>manifest.json</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{
    "name": "CatBlock",
    "version": "1.0",
    "description": "I can't has cheezburger!",
    "permissions": ["alarms", "webRequest", "webRequestBlocking", "activeTab", "tabs",
                    "https://*/*"],
    "background": {
      "scripts": ["background.js"]
    },
  
    "manifest_version": 2
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>background.js</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>chrome.webRequest.onBeforeRequest.addListener(
    function(info) {
      console.log("Cat intercepteddd: " + info.url);
     
    });
  
  chrome.webRequest.onBeforeRedirect.addListener(
      function(info) {
        console.log("Cat intercepteddd: " + info.url);
        
  });
  
  chrome.webRequest.onResponseStarted.addListener(
      function(info) {
        console.log("Cat intercepteddd: " + info.url);
      
  });</code></pre>
  </div>
  </div>
  </p>