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

Unified Diff: utils/pub/oauth2.dart

Issue 11416352: Handle OAuth2 AuthorizationExceptions in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: utils/pub/oauth2.dart
diff --git a/utils/pub/oauth2.dart b/utils/pub/oauth2.dart
index 7cc5c852a81d4c7b4cfc2331d1a45913e28e94c0..c7a87fdea7603274411a40b0f716f48f566f88e6 100644
--- a/utils/pub/oauth2.dart
+++ b/utils/pub/oauth2.dart
@@ -47,6 +47,16 @@ final _scopes = ['https://www.googleapis.com/auth/userinfo.email'];
/// the same as the credentials file stored in the system cache.
Credentials _credentials;
+/// Delete the cached credentials, if they exist.
+Future clearCredentials(SystemCache cache) {
+ _credentials = null;
+ var credentialsFile = _credentialsFile(cache);
+ return fileExists(credentialsFile).chain((exists) {
+ if (exists) return deleteFile(credentialsFile);
+ return new Future.immediate(null);
+ });
+}
+
/// Asynchronously passes an OAuth2 [Client] to [fn], and closes the client when
/// the [Future] returned by [fn] completes.
///

Powered by Google App Engine
This is Rietveld 408576698