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

Unified Diff: remoting/webapp/crd/js/oauth2_api_impl.js

Issue 945033002: Updated XHR API so call sites are more descriptive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@xhr-test
Patch Set: Created 5 years, 10 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
Index: remoting/webapp/crd/js/oauth2_api_impl.js
diff --git a/remoting/webapp/crd/js/oauth2_api_impl.js b/remoting/webapp/crd/js/oauth2_api_impl.js
index 5c18ea1776b35ec2d58d5f7e0d1b5d990e96fda4..18a71ce03d8e478d412e4430a63939eab7f468dc 100644
--- a/remoting/webapp/crd/js/oauth2_api_impl.js
+++ b/remoting/webapp/crd/js/oauth2_api_impl.js
@@ -93,14 +93,17 @@ remoting.OAuth2ApiImpl.prototype.refreshAccessToken = function(
}
};
- var parameters = {
- 'client_id': clientId,
- 'client_secret': clientSecret,
- 'refresh_token': refreshToken,
- 'grant_type': 'refresh_token'
- };
-
- remoting.xhr.post(this.getOAuth2TokenEndpoint_(), onResponse, parameters);
+ remoting.xhr.start({
+ method: 'POST',
+ url: this.getOAuth2TokenEndpoint_(),
+ onDone: onResponse,
+ formContent: {
+ 'client_id': clientId,
+ 'client_secret': clientSecret,
+ 'refresh_token': refreshToken,
+ 'grant_type': 'refresh_token'
+ }
+ });
};
/**
@@ -140,14 +143,18 @@ remoting.OAuth2ApiImpl.prototype.exchangeCodeForTokens = function(
}
};
- var parameters = {
- 'client_id': clientId,
- 'client_secret': clientSecret,
- 'redirect_uri': redirectUri,
- 'code': code,
- 'grant_type': 'authorization_code'
- };
- remoting.xhr.post(this.getOAuth2TokenEndpoint_(), onResponse, parameters);
+ remoting.xhr.start({
+ method: 'POST',
+ url: this.getOAuth2TokenEndpoint_(),
+ onDone: onResponse,
+ formContent: {
+ 'client_id': clientId,
+ 'client_secret': clientSecret,
+ 'redirect_uri': redirectUri,
+ 'code': code,
+ 'grant_type': 'authorization_code'
+ }
+ });
};
/**
@@ -177,9 +184,12 @@ remoting.OAuth2ApiImpl.prototype.getEmail = function(onDone, onError, token) {
onError(remoting.Error.fromHttpStatus(xhr.status));
}
};
- var headers = { 'Authorization': 'OAuth ' + token };
- remoting.xhr.get(this.getOAuth2ApiUserInfoEndpoint_(),
- onResponse, '', headers);
+ remoting.xhr.start({
+ method: 'GET',
+ url: this.getOAuth2ApiUserInfoEndpoint_(),
+ onDone: onResponse,
+ oauthToken: token
+ });
};
/**
@@ -210,9 +220,12 @@ remoting.OAuth2ApiImpl.prototype.getUserInfo =
onError(remoting.Error.fromHttpStatus(xhr.status));
}
};
- var headers = { 'Authorization': 'OAuth ' + token };
- remoting.xhr.get(this.getOAuth2ApiUserInfoEndpoint_(),
- onResponse, '', headers);
+ remoting.xhr.start({
+ method: 'GET',
+ url: this.getOAuth2ApiUserInfoEndpoint_(),
+ onDone: onResponse,
+ oauthToken: token
+ });
};
/** @type {remoting.OAuth2Api} */

Powered by Google App Engine
This is Rietveld 408576698