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

Side by Side Diff: remoting/webapp/me2mom/oauth2.js

Issue 8873026: Update the code that gets an OAuth2 access token. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * OAuth2 class that handles retrieval/storage of an OAuth2 token. 7 * OAuth2 class that handles retrieval/storage of an OAuth2 token.
8 * 8 *
9 * Uses a content script to trampoline the OAuth redirect page back into the 9 * Uses a content script to trampoline the OAuth redirect page back into the
10 * extension context. This works around the lack of native support for 10 * extension context. This works around the lack of native support for
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 * Redirect page to get a new OAuth2 Refresh Token. 229 * Redirect page to get a new OAuth2 Refresh Token.
230 * 230 *
231 * @return {void} Nothing. 231 * @return {void} Nothing.
232 */ 232 */
233 remoting.OAuth2.prototype.doAuthRedirect = function() { 233 remoting.OAuth2.prototype.doAuthRedirect = function() {
234 var GET_CODE_URL = 'https://accounts.google.com/o/oauth2/auth?' + 234 var GET_CODE_URL = 'https://accounts.google.com/o/oauth2/auth?' +
235 remoting.xhr.urlencodeParamHash({ 235 remoting.xhr.urlencodeParamHash({
236 'client_id': this.CLIENT_ID_, 236 'client_id': this.CLIENT_ID_,
237 'redirect_uri': this.REDIRECT_URI_, 237 'redirect_uri': this.REDIRECT_URI_,
238 'scope': this.SCOPE_, 238 'scope': this.SCOPE_,
239 'response_type': 'code' 239 'response_type': 'code',
240 'access_type': 'offline',
241 'approval_prompt': 'force'
240 }); 242 });
241 window.location.replace(GET_CODE_URL); 243 window.location.replace(GET_CODE_URL);
242 }; 244 };
243 245
244 /** 246 /**
245 * Asynchronously exchanges an authorization code for a refresh token. 247 * Asynchronously exchanges an authorization code for a refresh token.
246 * 248 *
247 * @param {string} code The new refresh token. 249 * @param {string} code The new refresh token.
248 * @param {function(XMLHttpRequest):void} onDone Callback to invoke on 250 * @param {function(XMLHttpRequest):void} onDone Callback to invoke on
249 * completion. 251 * completion.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * @return {?string} The email address, if it has been cached by a previous call 339 * @return {?string} The email address, if it has been cached by a previous call
338 * to getEmail, otherwise null. 340 * to getEmail, otherwise null.
339 */ 341 */
340 remoting.OAuth2.prototype.getCachedEmail = function() { 342 remoting.OAuth2.prototype.getCachedEmail = function() {
341 var value = window.localStorage.getItem(this.KEY_EMAIL_); 343 var value = window.localStorage.getItem(this.KEY_EMAIL_);
342 if (typeof value == 'string') { 344 if (typeof value == 'string') {
343 return value; 345 return value;
344 } 346 }
345 return null; 347 return null;
346 }; 348 };
OLDNEW
« 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