title: Angularjs oauth popup window, wait for JSON response
body: <p>I need to make an oauth request and I would like to start the request in a new window. </p>
  
  <p>I know that I can open the window like this:</p>
  
  <pre><code>var authWindow = $window.open("/auth/google/signin", "");
  </code></pre>
  
  <p>My server will handle the callback and respond with JSON: </p>
  
  <pre><code> app.get('/auth/google/signin',
      passport.authenticate('google', { scope: 'https://www.googleapis.com/auth/plus.login'}),
      function(req, res, next) {
        // The request will be redirected to Google for authentication, so this
        // function will not be called.
      }
    );
  
  app.get('/auth/google/callback',
      function(req, res, next) {
        passport.authenticate('google', function(err, user, info) {
          console.log('google authenticate callback');
  
          // do some stuff, then send back token and user...
  
          res.json({
            token:token,
            user: user
          });
  
        })(req, res, next);
      }
    );
  </code></pre>
  
  <p>I need to wait until the popup is redirected  to /auth/google/callback and the JSON data is returned from the server. </p>
  
  <p>How do I wait for the redirect and the JSON response from the server?</p>
  
  <p>Once I have waited and I have the JSON data what is the best way to give it back? Callback? postMessage()?</p>