Javascript 无法停止使用google plus登录
我正在使用下面的脚本通过谷歌获得用户身份验证,它工作正常,但问题是,没有点击g+登录按钮,它从浏览器获取谷歌会话并验证用户。如何使它在对接点击Javascript 无法停止使用google plus登录,javascript,google-plus,Javascript,Google Plus,我正在使用下面的脚本通过谷歌获得用户身份验证,它工作正常,但问题是,没有点击g+登录按钮,它从浏览器获取谷歌会话并验证用户。如何使它在对接点击 (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://plus.google.com/js/client:plusone.js'; va
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://plus.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
有没有办法在单击按钮时运行此功能?HTML
JS
我更喜欢使用谷歌Javascript Api
<a id="googleLogin"> Login with Google</a>
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></>
<script type="text/javascript">
$(document).ready(function(){
$("#googleLogin").bind("click", function(){
gapi.auth.authorize({client_id: YOUR_CONSUMER_KEY,
immediate: false,
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}, function(authResult){
YOUR CODE HERE
});
});
});
</script>
使用谷歌登录
$(文档).ready(函数(){
$(“#谷歌登录”).bind(“单击”,函数(){
gapi.auth.authorize({client\u id:YOUR\u CONSUMER\u KEY,
即时:错,
范围:“https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
},函数(authResult){
你的代码在这里
});
});
});
它停止自动身份验证,但不允许在单击时对用户进行身份验证。
<a id="googleLogin"> Login with Google</a>
<script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></>
<script type="text/javascript">
$(document).ready(function(){
$("#googleLogin").bind("click", function(){
gapi.auth.authorize({client_id: YOUR_CONSUMER_KEY,
immediate: false,
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}, function(authResult){
YOUR CODE HERE
});
});
});
</script>