Google api 正在删除已吊销的缓存Google访问令牌
在我的c#桌面应用程序中,我使用Google的API来验证和检索API的访问令牌。我注意到API将缓存这个令牌并再次使用它,直到它过期 使用我的浏览器,我可以通过以下方式撤销令牌:Google api 正在删除已吊销的缓存Google访问令牌,google-api,Google Api,在我的c#桌面应用程序中,我使用Google的API来验证和检索API的访问令牌。我注意到API将缓存这个令牌并再次使用它,直到它过期 使用我的浏览器,我可以通过以下方式撤销令牌: https://accounts.google.com/o/oauth2/revoke?token=1/xxxxxxx 我这样做是为了测试API如何处理被撤销的令牌。如前所述,API失败了。但我遇到的问题是让API使用新的令牌。它将继续检索缓存的令牌,即使它已被吊销。以下代码用于验证API的使用: credenti
https://accounts.google.com/o/oauth2/revoke?token=1/xxxxxxx
我这样做是为了测试API如何处理被撤销的令牌。如前所述,API失败了。但我遇到的问题是让API使用新的令牌。它将继续检索缓存的令牌,即使它已被吊销。以下代码用于验证API的使用:
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None);
如何让API删除缓存的令牌并请求新令牌?在获取新令牌之前,您必须注销。您可以在这里阅读OAuth2.0。 下面是我如何为我的windows phone 8应用程序做到这一点的: var string const GoogleTokenFileName=“Google.api.Auth.OAuth2.Responses.TokenResponse user” 公共异步任务LoginAsync() 公共异步任务注销() 希望能有帮助
{
await Logout();
_credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{
ClientId = _xmlfile.GoogleClientId,
ClientSecret = _xmlfile.GoogleClientSecret
}, new[] { Oauth2Service.Scope.UserinfoProfile }, "user", CancellationToken.None);
return session;
}
{
await new WebBrowser().ClearCookiesAsync();
if (_storageService.FileExists(GoogleTokenFileName))
{
_storageService.DeleteFile(GoogleTokenFileName);
}
}