How to Log User out of an App that uses Google OAuth2 Sign-In? How to Log User out of an App that uses Google OAuth2 Sign-In? flask flask

How to Log User out of an App that uses Google OAuth2 Sign-In?


The trick is to add prompt='consent'. There are different places to add it depending on the API's you are using. Here is one example based on bookshelf app:

from oauth2client.contrib.flask_util import UserOAuth2oauth2 = UserOAuth2()oauth2.init_app(    app,    scopes=['email', 'profile'],    authorize_callback=_request_user_info,    client_id=app.config['GOOGLE_OAUTH2_CLIENT_ID'],    client_secret=app.config['GOOGLE_OAUTH2_CLIENT_SECRET'],    prompt='consent')


You can refer the following link to revoke() the token assigned to your App. This will logout user from your app, but he will remain signed into google. Its mentioned on same link you have mentioned in your post above.

https://developers.google.com/identity/protocols/OAuth2WebServer#tokenrevoke