Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

iframe - Google Sign In for Web Apps not working with Internet Explorer

Using the quick start sample provided by Google I've been able to get Sign In for Web Apps to work in Chrome and Firefox. However it fails on Internet Explorer (version 11.) It will log the user into Google but the data-onsuccess call back is never called. And there are typically no notifications of any errors.

I've read a related question and have tried the suggestions around Trusted Sites. I've also experimented with adjusting when IE accepts 3rd party cookies but none of this seems to work.

The code for the test page I'm using is below (minus the client-id)

<html>
<head>
<meta charset="ISO-8859-1">
<title>Google Sign In</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="CLIENT_ID_FROM_GOOGLE_HERE">
<script>

function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
}

function signOut() {
    console.log(document);

    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
        console.log('User signed out.');
    });
}
</script>
</head>

<body>
<h1>Login</h1>
<p>
This is a simple page to test Google Sign In IE
</p>

<div class="g-signin2" data-onsuccess="onSignIn">
   Sign In Button Rendered Here
</div>

<div>
    <a href="#" onclick="signOut();">Sign out</a>
</div>
</body>
</html>

I've also tried this with code that uses listeners to listen for changes, as suggested by some answers. I've had no success with that approach either. Again works in Chrome/Firefox but not in IE.

Every so often (not all the time) I do see a "SCRIPT5: Access is denied" error message in the Console. Not exactly sure why but I do notice that when the page is ultimately loaded some of the Google Code is in an <iframe> and I'm wondering if this is part of the problem.

I host the above test page on a local instance of Apache (running in Windows) and I'm wondering if there are cross domain issues perhaps with the code in the <iframe> coming from Google.

I'm at a complete loss at the minute and I'm eager to know if anyone has managed to get this to work with IE. Is there some configuration required to IE to allow this to work? Are there changes to the code needed to make it work? Or is it just essentially unworkable in IE?

An alternate that I can try is the server side flow however I'm not sure if this avoids the problem and ideally I'd like to use client side approach.

Any feedback is appreciated. Thank you.

Edit: I've hosted a simple page that illustrates the problem. This page works in Chrome, Firefox, and Safari. But fails when IE (v11) is used.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Google Identity team fixed this in November. If you are continuing to see issues on the JavaScript demo hosted at GitHub, please report and issue.

You can check the following demos to see the sample work on Edge/IE11:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...