Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: remoting/webapp/oauth2.js

Issue 10260019: Fix sign-in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 +
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698