Google logout using api javascript/jquery

笑着哭i 提交于 2019-12-05 17:36:10

Do not log your users out of their Google Account when they sign out of your application. This behavior is unexpected and annoying to users.

You should, at most, be trying to figure out how to "log out" users of your application. (I put it in quotes, because depending on your implementation, the app might be faking it).

If you care only about hiding elements in the UI, you can set a variable, e.g. signedIn, and set or unset it when the user hits a login/logout button. If you care about persisting this state across sessions, use a cookie that stores the same value.

If you want to make sure the person on the other side of the keyboard is really the signed in user, you can use the max_auth_age parameter on the authorize call. If you set it to 0, users will need to re-authenticate with Google before your app gets a valid token. If you pair this with an automatic session expiration (like you'd see on a bank or health website), you can be relatively confident of the identity of the current user.

Nacho Coloma

If you relax the requirement to log out users from their Google account (as Dan explained, it's not a good idea) you can just revoke the OAuth token as explained in this other question.

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