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

Side by Side Diff: remoting/webapp/oauth2_callback.js

Issue 23891005: Fix OAuth "trampoline" content script to send a message with the oauth results rather than using a … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refresh window on new refresh token Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/oauth2_callback.html ('k') | 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * OAuth2 class that handles retrieval/storage of an OAuth2 token.
8 *
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
11 * chrome-extensions in OAuth2.
12 */
13
14 'use strict';
15
16 var remoting = remoting || {};
17
18 function retrieveRefreshToken() {
19 var query = window.location.search.substring(1);
20 var parts = query.split('&');
21 var queryArgs = {};
22 for (var i = 0; i < parts.length; i++) {
23 var pair = parts[i].split('=');
24 queryArgs[pair[0]] = pair[1];
25 }
26
27 if ('code' in queryArgs && 'state' in queryArgs) {
28 remoting.settings = new remoting.Settings();
29 var oauth2 = new remoting.OAuth2();
30 oauth2.exchangeCodeForToken(queryArgs['code'], queryArgs['state'],
31 function() {
32 window.location.replace(chrome.extension.getURL('main.html'));
33 });
34 } else {
35 window.location.replace(chrome.extension.getURL('main.html'));
36 }
37 }
38
39 window.addEventListener('load', retrieveRefreshToken, false);
OLDNEW
« no previous file with comments | « remoting/webapp/oauth2_callback.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698