我正在我的 API 中实现 google 加号,我正在关注的是这个(在服务器端访问):
https://developers.google.com/+/web/signin/server-side-flow
在第 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>
我已经完成了所有步骤,甚至在 python 端也能做到。
我遇到的问题是当我尝试将其更改为具有切换按钮之类的类的 input type:checkbox
时。
我想要的是当切换按钮位于上面的代码上时将起作用,或者将显示 google+ plus 登录弹出窗口。但事实并非如此。
这是我尝试执行的代码:
<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>
我错过了什么吗?
最佳答案
该按钮确实需要在 block 元素上呈现。在您的情况下,我会做的是使用gapi.auth.signIn在有人单击复选框后触发登录过程。
https://developers.google.com/+/web/signin/javascript-flow
这样做的一个缺点是有时使用弹出窗口拦截器可能会很棘手。如果是这种情况,那么我要做的就是选择该复选框,弹出一个灯箱或类似的灯箱,其中的登录按钮将像以前一样呈现。
关于javascript - 谷歌加登录复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21984213/