6

I have a Google sign-in on my site, which (after checking the token) redirects the user. It works exactly as desired on Chrome, but the redirect does not happen on either Internet Explorer or Edge, instead it just stays on the sign-in page.

<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script>
function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();
  console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.

  var id_token = googleUser.getAuthResponse().id_token;
  var userid;

  $.get("https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=" + id_token, function( data ) {

    window.location = 'check.php?userid=' + data.sub; // Once Google login is complete, redirects to check.php, sending userid via GET
    }, "json" );                                                                

}

</script>

Any ideas about what's stopping it from working on IE? My hunch is that it's to do with the window.location line, but I'm not good enough with javascript or understanding IE to figure out what!

The site is at http://test.cowenphysics.com.

Thanks

Edit: Looking at this similar question, it seems the problem is not due to my redirect, but the Google sign-in itself. That makes sense, as the sign-in button doesn't change state after sign-in. Basic Google Sign-In for Websites code not working in Internet Explorer 11

Edit 2: This does seem to be a bug at Google or IE's end. Even the official Google developer site with instructions on implementing sign-in does not work on Internet Explorer. Try the sign-in button on this page: https://developers.google.com/identity/sign-in/web/build-button

Community
  • 1
  • 1
Rob
  • 128
  • 1
  • 7
  • 29
  • 1
    This could be a Google-side bug. I've actually encountered it on many sites... – Katana314 Sep 04 '15 at 18:02
  • Don't know about Edge, but in IE, open your console (F12), go to the Network tab, click on the green "play" button. Reload the page, and try to sign in. When it's supposed to redirect, are there any calls appearing in the Network tab? Then, go to the Console tab, is there any error? – blex Sep 04 '15 at 18:05
  • did you try with an absolute url ? (including host) same behaviour here for ie7/8 : http://stackoverflow.com/questions/4818868/window-location-not-working-correctly-in-ie7-8 – Hacketo Sep 04 '15 at 18:05
  • @blex Thanks, I did as suggested and had two new calls. In the console tab I have an 'Invalid HTML5 DOCTYPE' error. – Rob Sep 04 '15 at 18:12
  • @blex Though actually, that error seems to be triggered on the page load, not from the redirect. – Rob Sep 04 '15 at 18:13
  • @Hacketo I just tried using an absolute URL and it still doesn't work, I'm afraid. – Rob Sep 04 '15 at 18:16
  • Do you have information on what the DOCTYPE is when it says 'Invalid HTML5 DOCTYPE' error. Look at the raw response and see what the DOCTYPE is. – Jeremy Foster Sep 06 '15 at 17:09
  • @JeremyFoster "HTML1524: Invalid HTML5 DOCTYPE. Consider using the interoperable form " "." – Rob Sep 07 '15 at 17:43

0 Answers0