0

I want to add a logout button to my google app which will redirect user back to the google login window. However, when I use a redirection link as per below:

https://www.google.com/accounts/Logout?continue=https://www.google.com/_ah/logout?continue=https://www.google.com/

the user is logged out but the website address in the adress bar remains the same and the screen gets empty.

After I refresh the website - the login screen is displayed (it's obvious since the user has been previously logged out).

I want the user to be logged out and redirected to a login screen in one, clear step. How the logout button should be placed in my google app script?

Mike79
  • 89
  • 1
  • 9
  • 1
    [This](https://stackoverflow.com/questions/12909332/how-to-logout-of-an-application-where-i-used-oauth2-to-login-with-google) might be useful to you. How about clearing the cache right after logging out? – Jescanellas Nov 12 '19 at 08:40
  • @Jescanellas Thank you. But when user clicks the button with the "logout" link I can't do anything later. Also, please note that the google app script is run inside the iframe. – Mike79 Nov 13 '19 at 17:35

1 Answers1

1

I have made two mistakes.

1) when returning HTML service in doGet(e) function I have enabled:

aHtmlService.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);

This should be omitted because you need to change location of the parent window (your google app script runs in iframe).

2) as google app script is run in the iframe - in order to logout and be redirected to the login window - you need to change the location of the parent window. So change the location like this way:

window.top.location='https://www.google.com/accounts/Logout?';

Mike79
  • 89
  • 1
  • 9