1

In a windows form application in c# that use google Drive API, I'm trying to sign out the user currently connected. I tried some solutions but no one is working. The code is executed but the user still connected when I'm looking in my browser.

Solution 1 (WebClient):

WebClient g = new WebClient();
g.DownloadString("https://www.google.com/accounts/Logout");

Solution 2:

Process.Start("https://accounts.google.com/Logout") //Working but open a browser

Solution 3 (WebRequest):

WebRequest request = WebRequest.Create("https://accounts.google.com/Logout");
request.Method = "GET";
request.GetResponse();

Thanks!

1 Answers1

0

Solution 2 seems to work. Google Sign-in authorized 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].

You can also revoke the users Token by calling https://accounts.google.com/o/oauth2/revoke?token={token}.

Check this SO ticket which might help.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • I'm in a windows form application so I asked me if it's possible to sign out of google without open a browser. Several people will connect their google account on my application so to avoid wrong access to another account, I need to disconnect the current google user. – Émile Pettersen-Coulombe Mar 23 '16 at 12:07