我一直在编写一个使用Google Drive API v2的桌面应用程序。我有以下代码:
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();
我第一次运行此代码时,它打开了一个浏览器并要求我授予应用程序权限,我做了。一切顺利,直到我意识到我使用了错误的Google帐户。那时我登录了错误的Google帐户并撤销了对我的应用程序的访问权限。现在,每当我运行相同的代码时,它都会引发异常:
错误:" invalid_grant",说明:"",Uri:""
当我检查服务并请求对象时,看起来oauth_token似乎不再被创建。
我知道我做了什么搞砸了,但我无法弄清楚如何纠正它,所以我可以使用其他Google帐户进行测试。我需要做什么?