| 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
|
|
|