How to destroy google drive token after task done?
c#, google-api-dotnet-client, google-drive-api, google-oauth
Solution
From release 1.8.2 (http://google-api-dotnet-client.blogspot.com/2014/05/announcing-release-of-182.html) which was just released earlier today, we support token revocation. It revokes the token and also deletes it form the data store.
All you have to do is the following:
await credential.RevokeTokenAsync(CancellationToken.None);
As simple as that.
UPDATE: Read more about token revocation in the Google APIs client library for .NET in this blogpost: http://peleyal.blogspot.com/2014/06/182-is-here.html
Problem
I am able to authenticate and perform actions on google drive using credential I got after authentication but this token is there for long long time. it says expires-in : 3600 so it should expire in 1hour but when I tried it after a month it uses that token and it worked. My requirement is after authentication and whatever task is being performed get complete, it should again ask for authentication to user if user initiate the program again. so basically I don't want token to be stored in client's system. Expires-in is not working for me as token get refreshed and is not asking again for Authentication. below is my code which I am using : ``` credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "<myid>.apps.googleusercontent.com", ClientSecret = "<Mysecret>" }, new[] { DriveService.Scope.Drive }, "user", CancellationToken.None).Result; // Create the service using the client credentials. DriveService service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "sampleapp" }); *****some task performed********* ``` now after this "some task" I want token to be destroy. Please help.