Index: remoting/webapp/oauth2.js |
diff --git a/remoting/webapp/oauth2.js b/remoting/webapp/oauth2.js |
index 2223d0a35d8520a2357627faab23276f744990e3..cdf1fd4e925669b3f80ab888fac98932e93bae6c 100644 |
--- a/remoting/webapp/oauth2.js |
+++ b/remoting/webapp/oauth2.js |
@@ -206,8 +206,11 @@ remoting.OAuth2.prototype.clearAccessToken = function() { |
*/ |
remoting.OAuth2.prototype.processTokenResponse_ = function(xhr) { |
if (xhr.status == 200) { |
- var tokens = jsonParseSafe(xhr.responseText); |
- if (tokens) { |
+ try { |
+ // Don't use jsonParseSafe here unless you move the definition out of |
+ // remoting.js, otherwise this won't work from the OAuth trampoline. |
+ // TODO(jamiewalch): Fix this once we're no longer using the trampoline. |
+ var tokens = JSON.parse(xhr.responseText); |
if ('refresh_token' in tokens) { |
this.setRefreshToken(tokens['refresh_token']); |
} |
@@ -221,8 +224,9 @@ remoting.OAuth2.prototype.processTokenResponse_ = function(xhr) { |
// Offset by a further 30 seconds to account for RTT issues. |
this.setAccessToken(tokens['access_token'], |
(tokens['expires_in'] - (120 + 30)) * 1000 + Date.now()); |
- } else { |
- console.error('Invalid "token" response from server.'); |
+ } catch (err) { |
+ console.error('Invalid "token" response from server:', |
+ /** @type {*} */ err); |
} |
} else { |
console.error('Failed to get tokens. Status: ' + xhr.status + |