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 diff --git a/pubspec.yaml b/pubspec.yaml index 7ff9b3bc848c7dd185a5a9ed7c499956da228ba2..94ea8c8f76bb2de0a438327bc1b32ee8a7bdcbb7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: http_throttle: "^1.0.0" json_rpc_2: "^1.0.0" mime: "^0.9.0" - oauth2: "^0.9.1" + oauth2: "^1.0.0" path: "^1.2.0" pool: "^1.0.0" pub_semver: "^1.2.0"