wpf 如何使用 Google+ API 注销用户?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17542278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:10:44  来源:igfitidea点击:

How to Sign out user using Google+ API?

c#wpfgoogle-apigoogle-plus

提问by Naren

I have been developing a desktop application in C#(WPF) using Google+ APIs.It's a simple application that provides a login page for Googleplus+, when user enters credentials & consents the application's permission request,it retrieve and display the User's profile information.

我一直在使用 Google+ API 在 C#(WPF) 中开发桌面应用程序。这是一个简单的应用程序,为 Googleplus+ 提供登录页面,当用户输入凭据并同意应用程序的权限请求时,它会检索并显示用户的个人资料信息。

Using the Google+ API I am able to retrieve the User's Profile information from Google+. But when I exit and open the application again, instead of login page it is going directly to the "Request for approval" page.

使用 Google+ API,我能够从 Google+ 检索用户的个人资料信息。但是当我退出并再次打开应用程序时,它不是登录页面而是直接进入“请求批准”页面。

The problem is in Internet Explorer,as it enables the "Stay signed in"option by default.I want to logout the user automatically every time the application closes.

问题出在 Internet Explorer 中,因为它默认启用“保持登录”选项。我想在每次应用程序关闭时自动注销用户。

After searching in google, I found by navigating the browser to this "https://accounts.google.com/Logout?&continue=http://www.google.com/" logout the user.

在谷歌搜索后,我发现通过将浏览器导航到这个“ https://accounts.google.com/Logout?&continue=http://www.google.com/”注销用户。

Is there any API in google+ for logging out programmatically the user or is this the only way?

google+ 中是否有任何 API 可用于以编程方式注销用户,或者这是唯一的方法?

回答by Burcu Dogan

Google+ API doesnt provide any methods to log a user out of the Google's single sign-on, because it shouldnt be handled at the layer of Google+ API.

Google+ API 没有提供任何方法让用户退出 Google 的单点登录,因为它不应该在 Google+ API 层进行处理。

Google+ authorize and authenticate you with an access token that is gathered by your auth flow that needs a signed-in Google account. If you want to log the user out of Google network, you should redirect him/her to

Google+ 使用需要登录 Google 帐户的身份验证流程收集的访问令牌对您进行授权和身份验证。如果您想将用户从 Google 网络中注销,您应该将他/她重定向到

https://accounts.google.com/Logout?&continue=[nextUrl]

or clear all of the cookies on launch or shutdown.

或在启动或关闭时清除所有 cookie。

If you want to revoke the access token you retrieved for your application, you should use https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevokethat will expire the existing access token.

如果您想撤销为应用程序检索到的访问令牌,则应使用https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke使现有访问令牌过期。

回答by bcorn

Google+ do not provide any api for signout or rather they didnt worked for me.

Google+ 不提供任何用于注销的 api,或者它们对我不起作用。

i found out other solution which i am mentioning here try this out. it worked out for me.

我发现了我在这里提到的其他解决方案,试试这个。它对我有用。

https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue='your site url'