summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/oauth2_callback.html
blob: 9c1fcc3a985413872d187b61eff3c5b4e07a3a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<!--
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<html>
  <head>
    <script src="oauth2.js"></script>
    <script src="plugin_settings.js"></script>
    <script src="xhr.js"></script>
  </head>
  <body>
    <script>
      function retrieveRefreshToken(query) {
        var parts = query.split('&');
        var queryArgs = {};
        for (var i = 0; i < parts.length; i++) {
          var pair = parts[i].split('=');
          queryArgs[pair[0]] = pair[1];
        }
        if ('code' in queryArgs) {
          var oauth2 = new remoting.OAuth2();
          oauth2.exchangeCodeForToken(queryArgs['code'], function() {
            window.location.replace(chrome.extension.getURL('main.html'));
          });
        } else {
          window.location.replace(chrome.extension.getURL('main.html'));
        }
      }

      retrieveRefreshToken(window.location.search.substring(1));
    </script>
  </body>
</html>