Search code examples
safarigoogle-authenticationgoogle-api-js-client

Client side JavaScript Google Sign In stopped working in Safari for Mac OS X v.10.15.2


After upgrading to Mac OS X version 10.15.2 sign in to Google with the google-api-javascript-client library has stopped working for some users in Safari.

The Safari developer console and network tab doesn't really tell me much regarding what the issue is for that specific Safari version.

Example snippet

<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="REPLACEME.apps.googleusercontent.com">
<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.
  console.log('Name: ' + profile.getName());
  console.log('Image URL: ' + profile.getImageUrl());
  console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
}
</script>

Documentation: https://developers.google.com/identity/sign-in/web


Solution

  • UPDATE: This specific issue has been resolved with the release of Mac OS X v10.15.3

    It seems that with the new update to Mac OS X v10.15.2 with the Safari preference Privacy > Tracking: Prevent cross-site tracking unchecked that sign in with the Google client side JavaScript library is broken.

    Though having the Tracking: Prevent cross-site tracking option checked in Safari privacy preferences doesn't make Google Sign In work in Safari Private Windows.

    See github issue here: https://github.com/google/google-api-javascript-client/issues/589

    This issue doesn't seem to be limited to the google-api-js-client library: https://www.reddit.com/r/Safari/comments/eaaanh/safari_1304_on_macos_changes_to_prevent_crosssite/