简体   繁体   English

谷歌加登录复选框

[英]google plus sign-in in checkbox

I am implementing the google plus sign in my API, the one I am following is this(which accesses in the server-side): 我正在我的API中实现谷歌加号,我正在遵循的是这个(在服务器端访问):

https://developers.google.com/+/web/signin/server-side-flow https://developers.google.com/+/web/signin/server-side-flow

At step 4 it adds the button this way: 在第4步,它以这种方式添加按钮:

<div id="signinButton">
  <span class="g-signin"
    data-scope="https://www.googleapis.com/auth/plus.login"
    data-clientid="YOUR_CLIENT_ID"
    data-redirecturi="postmessage"
    data-accesstype="offline"
    data-cookiepolicy="single_host_origin"
    data-callback="signInCallback">
  </span>
</div>

I have done all the steps, and was able to do it even in the python side. 我已经完成了所有步骤,甚至可以在python端完成它。 The one I am having problem with is when I am trying to change it into a input type:checkbox that has a class like a toggle button. 我遇到的问题是当我尝试将其更改为input type:checkbox具有类似切换按钮的类。 What I wanted is when the toggle button is on the above code will work, or the google+ plus login pop-up will show. 我想要的是当切换按钮打开上面的代码将起作用,或谷歌+加登录弹出窗口将显示。 But it doesnt. 但它没有。

Here is the code I tried doing: 这是我尝试过的代码:

            <label id="gConnect" class="switch" style="margin-left:30px; margin-top:6px;">
            <input type="checkbox" id="link-switch" class="input-switch g-signin" data-scope="https://www.googleapis.com/auth/plus.login"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-clientid="CLIENT_ID"
data-accesstype="offline"
data-cookiepolicy="single_host_origin"
data-callback="onSignInCallback" >
            <span class="switch-label" data-on="Yes" data-off="No"></span>
            <span class="switch-handle"></span>
            </label>

Am I missing something? 我错过了什么吗?

The button needs to render on a block element really. 该按钮需要真正渲染块元素。 What I would do in your case is use gapi.auth.signIn to trigger the sign in process once somebody clicks on the checkbox. 在你的情况下我会做的是使用gapi.auth.signIn在有人点击复选框后触发登录过程。

https://developers.google.com/+/web/signin/javascript-flow https://developers.google.com/+/web/signin/javascript-flow

The one downside with that is it can be tricky to work with pop up blockers at times. 这样做的一个缺点是,有时使用弹出窗口拦截器可能会很棘手。 If that's the the case then what I would do is have selecting the checkbox bring up a lightbox or similar with the sign in button in it rendered as you had before. 如果是这种情况,那么我要做的就是选择复选框,打开一个灯箱或类似的,其中的登录按钮就像之前一样呈现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM