How can I debug the Sign In With Google (GSI) library?

457 Views Asked by At

I'm using the Sign In With Google library (also known as GSI). It's not working as I expect, and I want to debug its behavior. How can I set the log level, or otherwise understand its behavior?

1

There are 1 best solutions below

0
jameshfisher On

You need to set the log_level option to 'debug', like so:

window.onload = function () {
  google.accounts.id.initialize({
    log_level: 'debug',  // THE ALL-IMPORTANT SETTING
    client_id: 'YOUR_GOOGLE_CLIENT_ID',
    callback: handleCredentialResponse
  });
  google.accounts.id.prompt();
};

You will now get explanations in the console. For example, if prompt() does cause the prompt to appear, you will see an explanation like:

[GSI_LOGGER]: User has closed One Tap before. Still in the cool down period.
[GSI_LOGGER]: Prompt will not be displayed

This setting is undocumented by Google (!), but extraordinarily helpful.