title: How to do Oauth Authentication using seperate new tab for verification of account?
body: <p>What is the Authentication Strategy for opening new (tab) Window for Oauth Authentication and returning to previous tab (logged In) upon successful authentication?</p>
  
  <p>I am using passportjs authentication strategies for Twitter, Facebook and Google. But all of that does authentication in the same window-tab. Is there a predefined strategy which I can follow to do the above?</p>
  
  <p>I can open the permission window in new account using a(target="_blank"), but it does not return to previous tab upon account authentication (by user).</p>
  
  <p>Edit (based on following answer)</p>
  
  <p>Login Page looks like:-</p>
  
  <pre><code>!!!
  html
  head
      script.(type='text/javascript')
          function newWindow (auth_target) {
              authWindow = window.open(auth_target);
              var authenticationSuccessUrl = "/home"
              authWindow.onClose = function () {
                  alert('onClose called.');
                  authWindow.close();
                  window.location = authenticationSuccessUrl;
              }
          }
  
  
      body
          button(type="button", onclick="newWindow('auth/google');").btnLogin with Gmail 
  </code></pre>
  
  <p>For New Window (home) i wrote:-</p>
  
  <pre><code>!!!
  html
  head
      script(type='text/javascript').
          function onAuthSuccess() {
  
              authWindow=window.location;
              window.onClose();
          }
  
  body(onload='onAuthSuccess();')
  </code></pre>
  
  <p>Its not a full code i was suppose to write, but even this does not work. If the Home page is called after an intermediate authentication window (by google, for password entry) the above code does not work, and window does not close. </p>
  
  <p>// just as some more information, ignore if not necessary
  Also please note, that,</p>
  
  <pre><code>    window.close()
  </code></pre>
  
  <p>works only if the parent window that triggered it open is open. If the current window is a standalone the above window.close() will not close the window. Likewise, the above Home page code fails to close current window.</p>