OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <html> | 8 <html> |
9 <head> | 9 <head> |
10 <script src="oauth2.js"></script> | 10 <script src="oauth2.js"></script> |
11 <script src="xhr.js"></script> | 11 <script src="xhr.js"></script> |
12 </head> | 12 </head> |
13 <body> | 13 <body> |
14 <div id="error" style="display:none;"> | |
15 Something went wrong getting OAuth2 token. | |
16 </div> | |
17 <script> | 14 <script> |
18 function retrieveRefreshToken(query) { | 15 function retrieveRefreshToken(query) { |
19 var parts = query.split('&'); | 16 var parts = query.split('&'); |
20 var queryArgs = {}; | 17 var queryArgs = {}; |
21 for (var i = 0; i < parts.length; i++) { | 18 for (var i = 0; i < parts.length; i++) { |
22 var pair = parts[i].split('='); | 19 var pair = parts[i].split('='); |
23 queryArgs[pair[0]] = pair[1]; | 20 queryArgs[pair[0]] = pair[1]; |
24 } | 21 } |
25 if ('code' in queryArgs) { | 22 if ('code' in queryArgs) { |
26 var oauth2 = new remoting.OAuth2(); | 23 var oauth2 = new remoting.OAuth2(); |
27 oauth2.exchangeCodeForToken(queryArgs['code'], function() { | 24 oauth2.exchangeCodeForToken(queryArgs['code'], function() { |
28 window.location.replace(chrome.extension.getURL('choice.html')); | 25 window.location.replace(chrome.extension.getURL('choice.html')); |
29 }); | 26 }); |
30 } else { | 27 } else { |
31 document.getElementById('error').style.display = 'block'; | 28 window.location.replace(chrome.extension.getURL('choice.html')); |
32 } | 29 } |
33 } | 30 } |
34 | 31 |
35 retrieveRefreshToken(window.location.search.substring(1)); | 32 retrieveRefreshToken(window.location.search.substring(1)); |
36 </script> | 33 </script> |
37 </body> | 34 </body> |
38 </html> | 35 </html> |
OLD | NEW |