Google Drive API invalid_grant after removing access

Posted by Sparafusile on Stack Overflow See other posts from Stack Overflow or by Sparafusile
Published on 2014-06-03T20:26:42Z Indexed on 2014/06/05 3:26 UTC
Read the original article Hit count: 186

Filed under:
|
|

I have been writing a desktop application that uses the Google Drive API v2. I have the following code:

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync
(
    new ClientSecrets { ClientId = ClientID, ClientSecret = ClientSecret },
    new[] { DriveService.Scope.Drive }, "user", CancellationToken.None
)
.Result;

this.Service = new DriveService( new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "My Test App",
} );

var request = this.Service.Files.List();
request.Q = "title = 'foo' and trashed = false";
var result = request.Execute();

The first time I ran this code it opened a browser and asked me to grant permissions to the App, which I did. Everything worked successfully until I realized I was using the wrong Google account. At that point I logged into the wrong Google account and revoked access to my App. Now, whenever I run the same code it throws an exception:

Error:"invalid_grant", Description:"", Uri:""

When I examine the service and request objects, it looks like the oauth_token isn't getting created any more.

enter image description here

I know what I did to mess things up, but I can't figure out how to correct it so I can use a different Google account for testing. What do I need to do?

© Stack Overflow or respective owner

Related posts about c#

Related posts about google-api