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

Unified Diff: lib/src/oauth2.dart

Issue 1344633003: Upgrade to oauth2 1.0.0. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/oauth2.dart
diff --git a/lib/src/oauth2.dart b/lib/src/oauth2.dart
index 3933a43f1bb0691afb8a28b3f6e3568195d9e0e4..384ae72d5bf08c41967272d6174d31d0b88586c3 100644
--- a/lib/src/oauth2.dart
+++ b/lib/src/oauth2.dart
@@ -111,16 +111,18 @@ Future withClient(SystemCache cache, Future fn(Client client)) {
///
/// If saved credentials are available, those are used; otherwise, the user is
/// prompted to authorize the pub client.
-Future<Client> _getClient(SystemCache cache) {
- return new Future.sync(() {
- var credentials = _loadCredentials(cache);
- if (credentials == null) return _authorize();
-
- var client = new Client(_identifier, _secret, credentials,
- httpClient: httpClient);
- _saveCredentials(cache, client.credentials);
- return client;
- });
+Future<Client> _getClient(SystemCache cache) async {
+ var credentials = _loadCredentials(cache);
+ if (credentials == null) return await _authorize();
+
+ var client = new Client(credentials,
+ identifier: _identifier,
+ secret: _secret,
+ // Google's OAuth2 API doesn't support basic auth.
+ basicAuth: false,
+ httpClient: httpClient);
+ _saveCredentials(cache, client.credentials);
+ return client;
}
/// Loads the user's OAuth2 credentials from the in-memory cache or the
@@ -172,9 +174,11 @@ String _credentialsFile(SystemCache cache) =>
Future<Client> _authorize() {
var grant = new AuthorizationCodeGrant(
_identifier,
- _secret,
authorizationEndpoint,
tokenEndpoint,
+ secret: _secret,
+ // Google's OAuth2 API doesn't support basic auth.
+ basicAuth: false,
httpClient: httpClient);
// Spin up a one-shot HTTP server to receive the authorization code from the
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698