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

Side by Side Diff: utils/pub/oauth2.dart

Issue 13132002: Version 0.4.3.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 7 years, 8 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 | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library oauth2; 5 library oauth2;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 final _scopes = ['https://www.googleapis.com/auth/userinfo.email']; 59 final _scopes = ['https://www.googleapis.com/auth/userinfo.email'];
60 60
61 /// An in-memory cache of the user's OAuth2 credentials. This should always be 61 /// An in-memory cache of the user's OAuth2 credentials. This should always be
62 /// the same as the credentials file stored in the system cache. 62 /// the same as the credentials file stored in the system cache.
63 Credentials _credentials; 63 Credentials _credentials;
64 64
65 /// Delete the cached credentials, if they exist. 65 /// Delete the cached credentials, if they exist.
66 void clearCredentials(SystemCache cache) { 66 void clearCredentials(SystemCache cache) {
67 _credentials = null; 67 _credentials = null;
68 var credentialsFile = _credentialsFile(cache); 68 var credentialsFile = _credentialsFile(cache);
69 if (!fileExists(credentialsFile)) return; 69 if (entryExists(credentialsFile)) deleteEntry(credentialsFile);
70
71 deleteFile(credentialsFile);
72 } 70 }
73 71
74 /// Asynchronously passes an OAuth2 [Client] to [fn], and closes the client when 72 /// Asynchronously passes an OAuth2 [Client] to [fn], and closes the client when
75 /// the [Future] returned by [fn] completes. 73 /// the [Future] returned by [fn] completes.
76 /// 74 ///
77 /// This takes care of loading and saving the client's credentials, as well as 75 /// This takes care of loading and saving the client's credentials, as well as
78 /// prompting the user for their authorization. It will also re-authorize and 76 /// prompting the user for their authorization. It will also re-authorize and
79 /// re-run [fn] if a recoverable authorization error is detected. 77 /// re-run [fn] if a recoverable authorization error is detected.
80 Future withClient(SystemCache cache, Future fn(Client client)) { 78 Future withClient(SystemCache cache, Future fn(Client client)) {
81 return _getClient(cache).then((client) { 79 return _getClient(cache).then((client) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 response.statusCode = 404; 198 response.statusCode = 404;
201 response.close(); 199 response.close();
202 } 200 }
203 }); 201 });
204 }) 202 })
205 .then((client) { 203 .then((client) {
206 log.message('Successfully authorized.\n'); 204 log.message('Successfully authorized.\n');
207 return client; 205 return client;
208 }); 206 });
209 } 207 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698