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

Unified Diff: chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js

Issue 3039002: Allow specifying optional parameters to pass to the Authorization token URL. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 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: chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js
diff --git a/chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js b/chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js
index 2aef56ce6706332f502424ca26b489e5537a364c..7e137107b2fcf3a384fa3b9dbebd81361442ba89 100644
--- a/chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js
+++ b/chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js
@@ -32,6 +32,14 @@ function ChromeExOAuth(url_request_token, url_auth_token, url_access_token,
this.key_token_secret = "oauth_token_secret";
this.callback_page = opt_args && opt_args['callback_page'] ||
"chrome_ex_oauth.html";
+ this.auth_params = {};
+ if (opt_args && opt_args['auth_params']) {
+ for (key in opt_args['auth_params']) {
+ if (opt_args['auth_params'].hasOwnProperty(key)) {
+ this.auth_params[key] = opt_args['auth_params'][key];
+ }
+ }
+ }
};
/*******************************************************************************
@@ -51,6 +59,9 @@ function ChromeExOAuth(url_request_token, url_auth_token, url_access_token,
* "consumer_secret" {String} OAuth consumer secret.
* "scope" {String} OAuth access scope.
* "app_name" {String} Application name.
+ * "auth_params" {Object} Additional parameters to pass to the
+ * Authorization token URL. For an example, 'hd', 'hl', 'btmpl':
+ * http://code.google.com/apis/accounts/docs/OAuth_ref.html#GetAuth
* @return {ChromeExOAuth} An initialized ChromeExOAuth object.
*/
ChromeExOAuth.initBackgroundPage = function(oauth_config) {
@@ -225,6 +236,9 @@ ChromeExOAuth.prototype.getAuthorizationHeader = function(url, method,
* "consumer_secret" {String} OAuth consumer secret.
* "scope" {String} OAuth access scope.
* "app_name" {String} Application name.
+ * "auth_params" {Object} Additional parameters to pass to the
+ * Authorization token URL. For an example, 'hd', 'hl', 'btmpl':
+ * http://code.google.com/apis/accounts/docs/OAuth_ref.html#GetAuth
* @return {ChromeExOAuth} An initialized ChromeExOAuth object.
*/
ChromeExOAuth.fromConfig = function(oauth_config) {
@@ -236,7 +250,8 @@ ChromeExOAuth.fromConfig = function(oauth_config) {
oauth_config['consumer_secret'],
oauth_config['scope'],
{
- 'app_name' : oauth_config['app_name']
+ 'app_name' : oauth_config['app_name'],
+ 'auth_params' : oauth_config['auth_params']
}
);
};
@@ -501,6 +516,11 @@ ChromeExOAuth.prototype.onRequestToken = function(callback, xhr) {
this.setTokenSecret(params['oauth_token_secret']);
var url = ChromeExOAuth.addURLParam(this.url_auth_token,
"oauth_token", token);
+ for (var key in this.auth_params) {
+ if (this.auth_params.hasOwnProperty(key)) {
+ url = ChromeExOAuth.addURLParam(url, key, this.auth_params[key]);
+ }
+ }
callback(url);
} else {
throw new Error("Fetching request token failed. Status " + xhr.status);
@@ -570,5 +590,4 @@ ChromeExOAuth.prototype.onAccessToken = function(callback, xhr) {
throw new Error("Fetching access token failed with status " + xhr.status);
}
}
-};
-
+};

Powered by Google App Engine
This is Rietveld 408576698