我们正在实现一个 C# MVC 应用程序,该应用程序使用此处提供的示例从 Google 的双击服务获取数据 https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#installed-applications . 我的问题如下。 这行代码
private static readonly IAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = "PUT_CLIENT_ID_HERE",
ClientSecret = "PUT_CLIENT_SECRET_HERE"
},
Scopes = new[] { DriveService.Scope.Drive },
DataStore = new FileDataStore("Drive.Api.Auth.Store")
});
将创建一个名为“Drive.Api.Auth.Store”的文件夹(如果尚不存在)并将身份验证 token 作为单独的文件保存在那里。 我的问题是如何从此文件夹中删除过期的 token ? 有什么想法吗?
请您参考如下方法:
我知道这是一篇较旧的帖子,但也许它对其他人有帮助...
通常,GoogleAuthorizationCodeFlow 负责在从 Google API 收到新 token 时自动刷新 token 。这就是您将 FileDataStore 传递给它并自动为您处理的原因。
但如果您仍然想显式删除,可以使用 FileDataStore 的 DeleteAsync 方法。
