启动Google登录按钮点击 [英] Initiate Google sign in on button click

查看:186
本文介绍了启动Google登录按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用google api登录我的网络应用程序。现在它的工作正常。但问题是当我进入登录页面时,sigin会自动启动。但我不希望这样。我希望用户先点击登录按钮,然后流程就会开始。

Hello I am using google api to sign in to my web application . Now Its working fine . But the problem is the sigin is initiated automatically as I go to my log in page . But I do not want that . I want the user to click the signin button first then the process will start .

我在按钮下方使用

<div class="g-signin2" data-onsuccess="onSignIn"></div>

google登录参考。

推荐答案

最好的方法是使用Java Script登录谷歌,我发现了。

Best way is to use Java Script to sign in to google as I have found out .

使用

script type="text/javascript">
      (function() {
       var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
       po.src = 'https://apis.google.com/js/client.js?onload=onLoadCallback';
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
     })();
</script>

初始化js。最后调用以下方法登录用户

to initialize js . And finally call below method to sign-in user

function login() 
{
  var myParams = {
    'clientid' : 'YOUR_CLIENT_ID.apps.googleusercontent.com', //You need to set client id
    'cookiepolicy' : 'single_host_origin',
    'callback' : 'loginCallback', //callback function
    'approvalprompt':'force',
    'scope' : 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read'
  };
  gapi.auth.signIn(myParams);
}

通过使用这个,我能够解决这个问题。现在用户需要点击登录才能登录

By using this I was able to solve this problem . Now User needs to click on sign-in to login

这篇关于启动Google登录按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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