google-plus - Google+ 退出时不弹出对话框

标签 google-plus single-sign-on

我的页面上有一个注销按钮,我通过这种方式启动:

$('#logout').click(function() {
    gapi.auth.signIn({
        'callback': function(authResult) {
            if (authResult['status']['signed_in']) {
                gapi.auth.signOut();
            } else {
                // second pass, signout succesful
            }
        }
    })
});

这最终会向 Google 发出两次调用(第一次是为了验证用户是否已登录,第二次是为了注销),因此两次都会通过回调代码。这也会导致 Google+ 登录窗口短暂弹出。

有没有办法直接调用gapi.auth.signOut()而不需要登录步骤?我有用户的 Google+ ID(以及 access_token),如果有帮助的话。

最佳答案

您不需要每次退出时都调用gapi.auth.signIn()。只需从任何地方调用gapi.auth.signOut()即可从您的应用启动注销过程(但仍在其他选项卡中登录到Google,这是一个很好的做法)。

示例是将gapi.auth.signOut() 事件附加到按钮上的onclick 事件;

<button onclick="gapi.auth.signOut();">Sign out</button>

关于google-plus - Google+ 退出时不弹出对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26928432/

相关文章:

android - statusCode=DEVELOPER_ERROR 在谷歌登录

android - Eclipse 在将 GooglePlay 服务库导入项目时崩溃

javascript - 谷歌加自定义分享按钮回调

google-app-engine - 使用 Google+ API 登录后获取电子邮件 ID/用户名

android - 如何在android中获取google plus相册列表

java - 为 Web 应用程序单点登录选择 Kerberos (SPNEGO) Java 库

java - 如何在 java 中使用 Windows 凭据自动登录?

ruby-on-rails - 如何在 Azure AD 上使用 SSO 设置 RoR 应用程序

asp.net-mvc - 跨两个站点使用 SSL 进行 MVC 单点登录

android - 如何使用 ADFS STS 为 Android 和 iPhone 应用程序执行基于声明的 SSO?