Index: Src/GoogleApis.Authentication.OAuth2/OAuth2Authenticator.cs
===================================================================
--- a/Src/GoogleApis.Authentication.OAuth2/OAuth2Authenticator.cs
+++ b/Src/GoogleApis.Authentication.OAuth2/OAuth2Authenticator.cs
@@ -17,6 +17,7 @@
using System;
using System.Net;
using System.Net.Http;
+using System.Threading.Tasks;
using DotNetOpenAuth.OAuth2;
@@ -34,9 +35,7 @@
private readonly TClient tokenProvider;
private bool noCaching;
- ///
- /// Creates a new OAuth2 authenticator.
- ///
+ /// Creates a new OAuth2 authenticator.
/// The client which is used for requesting access and refresh tokens.
/// The method which provides the initial authorization for the provider.
public OAuth2Authenticator(TClient tokenProvider,
@@ -49,9 +48,7 @@
this.authProvider = authProvider;
}
- ///
- /// The current state of this authenticator
- ///
+ /// The current state of this authenticator.
public IAuthorizationState State { get; private set; }
///
@@ -125,11 +122,16 @@
}
///
- /// Override handle response to refresh the token when Unauthorized status code is received.
+ /// Overrides handle response to refresh the token when Unauthorized status code is received.
///
- public bool HandleResponse(HandleUnsuccessfulResponseArgs args)
+ public Task HandleResponseAsync(HandleUnsuccessfulResponseArgs args)
{
- return args.Response.StatusCode == HttpStatusCode.Unauthorized && tokenProvider.RefreshToken(State, null);
+ var result = args.Response.StatusCode == HttpStatusCode.Unauthorized &&
+ tokenProvider.RefreshToken(State, null);
+
+ TaskCompletionSource tcs = new TaskCompletionSource();
+ tcs.SetResult(result);
+ return tcs.Task;
}
}
}
\ No newline at end of file