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

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

Issue 12191008: Get the pub oauth2 test passing locally. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 /// Gets a new OAuth2 client. If saved credentials are available, those are 95 /// Gets a new OAuth2 client. If saved credentials are available, those are
96 /// used; otherwise, the user is prompted to authorize the pub client. 96 /// used; otherwise, the user is prompted to authorize the pub client.
97 Future<Client> _getClient(SystemCache cache) { 97 Future<Client> _getClient(SystemCache cache) {
98 return defer(() { 98 return defer(() {
99 var credentials = _loadCredentials(cache); 99 var credentials = _loadCredentials(cache);
100 if (credentials == null) return _authorize(); 100 if (credentials == null) return _authorize();
101 101
102 var client = new Client(_identifier, _secret, credentials, 102 var client = new Client(_identifier, _secret, credentials,
103 httpClient: curlClient); 103 httpClient: httpClient);
104 _saveCredentials(cache, client.credentials); 104 _saveCredentials(cache, client.credentials);
105 return client; 105 return client;
106 }); 106 });
107 } 107 }
108 108
109 /// Loads the user's OAuth2 credentials from the in-memory cache or the 109 /// Loads the user's OAuth2 credentials from the in-memory cache or the
110 /// filesystem if possible. If the credentials can't be loaded for any reason, 110 /// filesystem if possible. If the credentials can't be loaded for any reason,
111 /// the returned [Future] will complete to null. 111 /// the returned [Future] will complete to null.
112 Credentials _loadCredentials(SystemCache cache) { 112 Credentials _loadCredentials(SystemCache cache) {
113 log.fine('Loading OAuth2 credentials.'); 113 log.fine('Loading OAuth2 credentials.');
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 'Pub needs your authorization to upload packages on your behalf.\n' 194 'Pub needs your authorization to upload packages on your behalf.\n'
195 'In a web browser, go to $authUrl\n' 195 'In a web browser, go to $authUrl\n'
196 'Then click "Allow access".\n\n' 196 'Then click "Allow access".\n\n'
197 'Waiting for your authorization...'); 197 'Waiting for your authorization...');
198 198
199 return completer.future.then((client) { 199 return completer.future.then((client) {
200 log.message('Successfully authorized.\n'); 200 log.message('Successfully authorized.\n');
201 return client; 201 return client;
202 }); 202 });
203 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698