Google+ JavaScript API:如何检测用户登录状态? [英] Google+ JavaScript API: How to detect user sign in status?

查看:89
本文介绍了Google+ JavaScript API:如何检测用户登录状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经部署了Google+登录按钮,现在我必须提供退出按钮,在此之前,我需要知道用户是否仍处于登录状态,然后才能显示或隐藏此按钮.

I have deployed Google+ Sign-in Button, now I have to provide Sign-Out Button, before that, I need to know whether the user is still signed in, by which I can then show or hide this button.

我找到了以下文档: gapi.auth.checkSessionState(sessionParams,回调): https://developers.google.com/+/web/api /javascript?hl = zh-CN#gapiauthchecksessionstatesessionparams_callback

I found this documentation: gapi.auth.checkSessionState(sessionParams, callback): https://developers.google.com/+/web/api/javascript?hl=en#gapiauthchecksessionstatesessionparams_callback

有人可以演示如何使用它吗?

Could someone demo how to use it ?

非常感谢.

推荐答案

如果您已经添加了登录按钮,则无需使用单独的函数调用来确定用户的登录状态.登录按钮的回调将在登录时,页面加载时或用户登录状态更改时触发.页面加载触发器(立即模式)也将有助于指示该用户是否是Google登录用户.

You don't need to use a separate function call to determine the user's signed in state if you've already added the sign-in button. The sign-in button's callback is going to trigger either on sign-in, when the page loads, or any time that the user's signed-in status changes. The page load trigger (immediate mode), will also help to indicate if the user is a Google signed-in user or not.

请参见监视用户的登录状态,其中显示了不同的内容您可以检查的状态字段(Google已登录,应用已登录或已退出).

See monitoring the user's signed in status, which shows the different status fields that you can check (Google signed in, app signed in, or signed out).

这篇关于Google+ JavaScript API:如何检测用户登录状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆