Google Oauth2 使用 javascript API 登录不适用于 IE

Google Oauth2 sign in using javascript API is not working with IE

本文关键字:不适用 适用于 IE 登录 API Oauth2 使用 javascript Google      更新时间:2023-09-26

我正在使用Google oauth2 javascript api来验证我的应用程序的用户。这在Firefox和chrome中工作正常,但在IE中则不行。我已经尝试过IE 8,9和10,但徒劳无功。我在网上搜索了很多,但没有得到任何解决方案。我已经14285480和14830177地完成了堆栈溢出问题。如果这是谷歌中现有的错误,那么还有其他方法吗? 我正在尝试下面的代码。我没有足够的堆栈溢出点来评论任何问题,所以问一个新问题。请帮忙。

这是我的代码

 <html>
    <head>
    <script type="text/javascript">       
        window.setTimeout(function() {        
            var po = document.createElement('script'); 
            po.type = 'text/javascript'; po.async = true;        
            po.src = 'https://apis.google.com/js/client:plusone.js';        
            var s = document.getElementsByTagName('script')[0]; 
            s.parentNode.insertBefore(po, s);      
        },1000)(); 
        function signinCallback(authResult) {   
            if (authResult['access_token']) { 
                 document.getElementById('signinButton').setAttribute('style', 'display: none');
            } 
            else if (authResult['error']) {   
                 console.log('Sign-in state: ' + authResult['error']);   
            } 
        }
    </script>
    </head>
    <body>
    <span id="signinButton">
        <span 
        class="g-signin" 
        data-callback="signinCallback" 
        data-clientid="my clinetid" 
        data-cookiepolicy="single_host_origin" 
        data-requestvisibleactions="http://schemas.google.com/AddActivity"     
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">   
        </span> 
    </span> 
    </body>
    </html>

试试这个。

<html>
    <head>
    <script type="text/javascript">       
function signinCallback(authResult) {   
            if (authResult['access_token']) { 
                 document.getElementById('signinButton').setAttribute('style', 'display: none');
            } 
            else if (authResult['error']) {   
                 console.log('Sign-in state: ' + authResult['error']);   
            } 
        }
    </script>
    </head>
    <body>
    <span id="signinButton">
        <span 
        class="g-signin" 
        data-callback="signinCallback" 
        data-clientid="my clinetid" 
        data-cookiepolicy="single_host_origin" 
        data-requestvisibleactions="http://schemas.google.com/AddActivity"     
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">   
        </span> 
    </span>
<script type="text/javascript">
  var po = document.createElement('script'); 
  po.type = 'text/javascript'; po.async = true;        
  po.src = 'https://apis.google.com/js/client:plusone.js';        
  var s = document.getElementsByTagName('script')[0]; 
  s.parentNode.insertBefore(po, s);      
</script>
    </body>
    </html>