Search code examples
htmlauthenticationgoogle-signin

Google Identity Toolkit - Google Sign in Error 400 after login


I am currently working on an admin system to edit a websites contents and require a login system that allows me to check if a user is within a certain Google group, so I am using the Google Sign in platform (as part of the Google Identity Toolkit), however, when I click 'sign in' and select the account, the widget just displays 'Error 400: Thats all we know'.

I have re-written the sign in system from scratch multiple times, following the documentation on the Google Sign In website to the letter. My code is as follows:
Head:

<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="User-ID.apps.googleusercontent.com">

Body:

<div class="g-signin2" data-onsucess="onSignIn"></div>
<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());
}
</script>

My Google Developers project is set up to accept Javascript origins from both localhost and 127.0.0.1 (even though they're the same thing), and has no redirect URIs, as they are not needed.

I have checked the Google Status website and everything appears to be fine, as well as sought help from my ICT teacher, so I am completely stuck, any help would be appreciated!

Thanks in advance :)


Solution

  • Using http://127.0.0.1 in the Google developer credentials for JavaScript origins simply won't work.