禁止使用Google Plus自动登录 [英] Prevent auto sign in with Google plus

查看:96
本文介绍了禁止使用Google Plus自动登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为网站实施Google+登录.

I am trying to implement Google+ sign in for web sites.

我想要的流程是:

  1. 用户登陆登录页面
  2. 点击Google登录按钮
  3. 我收到电子邮件并在服务器端进行处理

问题是,无论我尝试使用哪种脚本,Google始终会调用并取消自动登录.我希望仅在用户单击按钮时启动它,并阻止自动触发Google事件.

The problem is, whatever script I try, Google always invoking and UNWANTED auto sign in. I want it to be initiated only when user clicks the button and prevent auto triggering google events.

推荐答案

您提到的自动登录"是默认情况下Google+登录方法的功能.如果要完全控制登录过程,则需要使用 Google Plus API 和手动完成整个OAuth过程.我不知道您正在开发什么平台,但是有很多客户端库用于Google+ API.

The 'auto sign in' thing you mention is how the Google+ Sign In method functions by default. If you want full control of the sign in process, you need to use the Google Plus API and manually go through the whole OAuth process. I don't know what platform you're developing on but there are plenty of client libraries for the Google+ API.

如果您坚持使用Google+ JavaScript库,请使用以下一种方法:Google Plus登录按钮具有 data-callback 属性. object 传递到此回调函数中.该对象具有status属性,您可以使用该属性检查登录是否如您所述是自动"完成的,还是在用户单击登录按钮之后进行的.

If you insist on using the Google+ JavaScript library, here's one option: The Google Plus Sign In button has a data-callback attribute. An object is passed into this callback function. That object has a status property which you can use to check whether the sign-in was made 'automatically' as you mention, or was made after the user clicked the sign-in button.

function google_plus_signin_callback(authResult){
    if(authResult.status.method == 'AUTO'){
        // handle auto sign-in scenario
    }else if(authResult.status.method == 'PROMPT') {
        // handle user initiated sign-in scenario
    }
}

因此,如果用户已自动登录,则可以使用 sign out 方法将其注销,或者您可以尝试其他操作,具体取决于您希望应用程序如何运行.

So if the user was signed in automatically, you can use the sign out method to sign her out or you can try doing something else depending on how you want your application to behave.

这篇关于禁止使用Google Plus自动登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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