在c#中使用google Drive API的Windows窗体应用程序中,我正在尝试退出当前连接的用户。我尝试了一些解决方案,但没有人工作。代码已执行但用户在浏览浏览器时仍然连接。
解决方案1(WebClient):
WebClient g = new WebClient();
g.DownloadString("https://www.google.com/accounts/Logout");
解决方案2:
Process.Start("https://accounts.google.com/Logout") //Working but open a browser
解决方案3(WebRequest):
WebRequest request = WebRequest.Create("https://accounts.google.com/Logout");
request.Method = "GET";
request.GetResponse();
谢谢!
答案 0 :(得分:0)
解决方案2似乎有效。 Google登录授权您使用需要已登录Google帐户的身份验证流程收集的访问令牌。如果您要将用户退出Google网络,则应将他/她重定向到https://accounts.google.com/Logout?&continue=[nextUrl]
。
您还可以通过调用https://accounts.google.com/o/oauth2/revoke?token={token}
撤消用户令牌。
查看SO ticket这可能会有所帮助。