Receive notifications on the prompt UI status

To facilitate your users to sign in or sign up, you can communicate with multiple identity providers to find available credentials. You might want to know our prompt UI status so that you can call the next identity provider.

To be notified about the prompt UI status at different moments, set a callback function name to the data-moment_callback attribute, or a function to the prompt() method if you use the JavaScript API.

Notifications are sent for the following moments:

  • Display moment: This occurs after the prompt() method is called. The notification contains a boolean value to indicate whether the UI is displayed or not.

  • Skipped moment: This occurs when the One Tap prompt is closed by an auto cancel, a manual cancel, or when Google fails to issue a credential, such as when the selected session is signed out of Google.

    In this case, we recommend that you continue on to the next identity providers, if there are any.

  • Dismissed moment: This occurs when Google successfully retrieves a credential, or a user wants to stop the credential retrieval flow. For example, when the user begins to input their username and password into the login dialog, you can call the google.accounts.id.cancel() method to close the One Tap prompt and trigger a dismissed moment.

The following code example implements a skipped moment:

<script>
  function continueWithNextIdp(notification) {
      if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
          // try Next provider if One Tap is not displayed or skipped
      }
  }
</script>
...
<div id="g_id_onload"
     data-client_id="YOUR_GOOGLE_CLIENT_ID"
     data-login_uri="https://your.domain/your_login_endpoint"
     data-moment_callback="continueWithNextIdp"
</div>