Chromium Code Reviews| Index: remoting/webapp/oauth2.js |
| diff --git a/remoting/webapp/oauth2.js b/remoting/webapp/oauth2.js |
| index 9956f5a026edb30fca3157283517fe91aa7515f2..7ec220833ef6bfc39b5f8c65f387473f1c1705ef 100644 |
| --- a/remoting/webapp/oauth2.js |
| +++ b/remoting/webapp/oauth2.js |
| @@ -492,10 +492,10 @@ remoting.OAuth2.prototype.getEmail = function(onOk, onError) { |
| var onResponse = function(xhr) { |
| var email = null; |
| if (xhr.status == 200) { |
| - // TODO(ajwong): See if we can't find a JSON endpoint. |
| - email = xhr.responseText.split('&')[0].split('=')[1]; |
| - window.localStorage.setItem(that.KEY_EMAIL_, email); |
| - onOk(email); |
| + var result = |
| + /** @type {{email: string}} */ (jsonParseSafe(xhr.responseText)); |
| + window.localStorage.setItem(that.KEY_EMAIL_, result.email); |
| + onOk(result.email); |
|
Jamie
2013/01/09 18:51:09
I think we could benefit from some sanity-checking
rmsousa
2013/01/09 20:34:39
Done.
|
| return; |
| } |
| console.error('Unable to get email address:', xhr.status, xhr); |
| @@ -509,8 +509,7 @@ remoting.OAuth2.prototype.getEmail = function(onOk, onError) { |
| /** @param {string} token The access token. */ |
| var getEmailFromToken = function(token) { |
| var headers = { 'Authorization': 'OAuth ' + token }; |
| - // TODO(ajwong): Update to new v2 API. |
| - remoting.xhr.get('https://www.googleapis.com/userinfo/email', |
| + remoting.xhr.get('https://www.googleapis.com/oauth2/v1/userinfo', |
| onResponse, '', headers); |
| }; |