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

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

Issue 3107017: Merge 54841 - Allow specifying optional parameters to pass to the Authorizati... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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
===================================================================
--- chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js (revision 56269)
+++ chrome/common/extensions/docs/examples/extensions/oauth_contacts/chrome_ex_oauth.js (working copy)
@@ -32,6 +32,14 @@
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 @@
* "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 @@
* "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 @@
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 @@
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 @@
throw new Error("Fetching access token failed with status " + xhr.status);
}
}
-};
-
+};

Powered by Google App Engine
This is Rietveld 408576698