How to Sign out user using Google+ API?

佐手、 提交于 2019-12-06 17:05:39

问题


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.

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.

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.

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.

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


回答1:


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+ 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

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

or clear all of the cookies on launch or shutdown.

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




回答2:


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

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'


来源:https://stackoverflow.com/questions/17542278/how-to-sign-out-user-using-google-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!