<html>
  <head>
  </head>
  <body>
    <script>
      var code = decodeURIComponent(window.location.toString().match(/code=(.*)&/, '')[1]);
      var state = decodeURIComponent(window.location.toString().match(/state=(.*)/, '')[1]);
      window.opener.postMessage({code: code, state: state}, window.location);
      window.close();
    </script>
  </body>
</html>

<html>
  <head>
  </head>
  <body>
    <script>
      var queryParams = window.location.search.slice(1).split(/&/).map(function(s) { return s.split(/=/); })
      var queries = new Map(queryParams);
      var code = decodeURIComponent(queries.get("code"));
      var state = decodeURIComponent(queries.get("state"));
      window.opener.postMessage({code: code, state: state}, window.location);
      window.close();
    </script>
  </body>
</html>

Make oauth redirect message handler a little more robust
Make oauth redirect message handler a little more robust
