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

Unified Diff: pkg/oauth2/lib/src/client.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « pkg/oauth2/lib/src/authorization_code_grant.dart ('k') | pkg/oauth2/lib/src/credentials.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/oauth2/lib/src/client.dart
diff --git a/pkg/oauth2/lib/src/client.dart b/pkg/oauth2/lib/src/client.dart
index a397c00fc01807c121c1643e1e08d73a3ff67e70..fd315bb3fb94e2994443779a55d4e830ff261e40 100644
--- a/pkg/oauth2/lib/src/client.dart
+++ b/pkg/oauth2/lib/src/client.dart
@@ -4,6 +4,7 @@
library client;
+import 'dart:async';
import 'dart:uri';
import '../../../http/lib/http.dart' as http;
@@ -81,14 +82,14 @@ class Client extends http.BaseClient {
/// will also automatically refresh this client's [Credentials] before sending
/// the request if necessary.
Future<http.StreamedResponse> send(http.BaseRequest request) {
- return async.chain((_) {
+ return async.then((_) {
if (!credentials.isExpired) return new Future.immediate(null);
if (!credentials.canRefresh) throw new ExpirationException(credentials);
return refreshCredentials();
- }).chain((_) {
+ }).then((_) {
request.headers['authorization'] = "Bearer ${credentials.accessToken}";
return _httpClient.send(request);
- }).transform((response) {
+ }).then((response) {
if (response.statusCode != 401 ||
!response.headers.containsKey('www-authenticate')) {
return response;
@@ -122,7 +123,7 @@ class Client extends http.BaseClient {
/// [newScopes]. These must be a subset of the scopes in the
/// [Credentials.scopes] field of [Client.credentials].
Future<Client> refreshCredentials([List<String> newScopes]) {
- return async.chain((_) {
+ return async.then((_) {
if (!credentials.canRefresh) {
var prefix = "OAuth credentials";
if (credentials.isExpired) prefix = "$prefix have expired and";
@@ -131,7 +132,7 @@ class Client extends http.BaseClient {
return credentials.refresh(identifier, secret,
newScopes: newScopes, httpClient: _httpClient);
- }).transform((credentials) {
+ }).then((credentials) {
_credentials = credentials;
return this;
});
« no previous file with comments | « pkg/oauth2/lib/src/authorization_code_grant.dart ('k') | pkg/oauth2/lib/src/credentials.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698