OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 try { | 74 try { |
75 client.close(); | 75 client.close(); |
76 // Be sure to save the credentials even when an error happens. Also be | 76 // Be sure to save the credentials even when an error happens. Also be |
77 // sure to pipe the exception from `future` to `completer`. | 77 // sure to pipe the exception from `future` to `completer`. |
78 chainToCompleter( | 78 chainToCompleter( |
79 _saveCredentials(cache, client.credentials).then((_) => future), | 79 _saveCredentials(cache, client.credentials).then((_) => future), |
80 completer); | 80 completer); |
81 } catch (e, stackTrace) { | 81 } catch (e, stackTrace) { |
82 // whenComplete will drop exceptions on the floor. We want to ensure | 82 // whenComplete will drop exceptions on the floor. We want to ensure |
83 // that any programming errors here don't go un-noticed. See issue 4127. | 83 // that any programming errors here don't go un-noticed. See issue 4127. |
84 completer.completeException(e, stackTrace); | 84 completer.completeError(e, stackTrace); |
85 } | 85 } |
86 }); | 86 }); |
87 return completer.future; | 87 return completer.future; |
88 }).catchError((e) { | 88 }).catchError((e) { |
89 if (e is ExpirationException) { | 89 if (e is ExpirationException) { |
90 log.error("Pub's authorization to upload packages has expired and " | 90 log.error("Pub's authorization to upload packages has expired and " |
91 "can't be automatically refreshed."); | 91 "can't be automatically refreshed."); |
92 return withClient(cache, fn); | 92 return withClient(cache, fn); |
93 } else if (e is AuthorizationException) { | 93 } else if (e is AuthorizationException) { |
94 var message = "OAuth2 authorization failed"; | 94 var message = "OAuth2 authorization failed"; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 'Pub needs your authorization to upload packages on your behalf.\n' | 209 'Pub needs your authorization to upload packages on your behalf.\n' |
210 'In a web browser, go to $authUrl\n' | 210 'In a web browser, go to $authUrl\n' |
211 'Then click "Allow access".\n\n' | 211 'Then click "Allow access".\n\n' |
212 'Waiting for your authorization...'); | 212 'Waiting for your authorization...'); |
213 | 213 |
214 return completer.future.then((client) { | 214 return completer.future.then((client) { |
215 log.message('Successfully authorized.\n'); | 215 log.message('Successfully authorized.\n'); |
216 return client; | 216 return client; |
217 }); | 217 }); |
218 } | 218 } |
OLD | NEW |