Index: Src/GoogleApis.Auth.WP/OAuth2/GoogleWebAuthorizationBroker.cs =================================================================== --- a/Src/GoogleApis.Auth.WP/OAuth2/GoogleWebAuthorizationBroker.cs +++ b/Src/GoogleApis.Auth.WP/OAuth2/GoogleWebAuthorizationBroker.cs @@ -75,6 +75,23 @@ return await AuthorizeAsyncCore(initializer, scopes, user, taskCancellationToken).ConfigureAwait(false); } + /// + /// Asynchronously reauthorizes the user. This method should be called if the users want to authorize after + /// they revoked the token. + /// + /// The current user credential. Its will be + /// updated. + /// Cancellation token to cancel an operation. + public static async Task ReauthorizeAsync(UserCredential userCredential, + CancellationToken taskCancellationToken) + { + var installedApp = new AuthorizationCodeWPInstalledApp(userCredential.Flow); + // Create an authorization code installed app instance and authorize the user. + UserCredential newUserCredential = await installedApp.AuthorizeAsync(userCredential.UderId, + taskCancellationToken).ConfigureAwait(false); + userCredential.Token = newUserCredential.Token; + } + /// The core logic for asynchronously authorizing the specified user. /// The authorization code initializer. /// @@ -83,13 +100,14 @@ /// The user to authenticate. /// Cancellation token to cancel an operation. /// User credential. - private static async Task AuthorizeAsyncCore(AuthorizationCodeFlow.Initializer initializer, - IEnumerable scopes, string user, CancellationToken taskCancellationToken) + private static async Task AuthorizeAsyncCore( + GoogleAuthorizationCodeFlow.Initializer initializer, IEnumerable scopes, string user, + CancellationToken taskCancellationToken) { initializer.Scopes = scopes; initializer.DataStore = new StorageDataStore(); - var installedApp = new AuthorizationCodeWPInstalledApp(initializer); + var installedApp = new AuthorizationCodeWPInstalledApp(new GoogleAuthorizationCodeFlow(initializer)); return await installedApp.AuthorizeAsync(user, taskCancellationToken).ConfigureAwait(false); } }