jquerygoogle-apigoogle-signingoogle-one-tap

Google one tap signing `intermediate_iframe_close_callback ` not working


I am using google one-tap sign on my website, I want to handle user close events(escape and close button) and want to show some google sign-in button.

I have tried to use intermediate_iframe_close_callback callback to handle the close event as per doc, but it's not working. Here is the code that I am using:

<script src="https://accounts.google.com/gsi/client" async defer></script>
google.accounts.id.initialize({
  client_id: process.env.analyticsConfig.googleOAuth.clientId,
  callback: handleGoogleOnetapResponse,
  context: 'signup',
  prompt_parent_id: prompt_parent_id,
  cancel_on_tap_outside: false,
  intermediate_iframe_close_callback: logBeforeClose
});
google.accounts.id.prompt();

Can you any one please help, Thanks in advance.


Solution

  • As written in the official documentation you posted, it says:

    The intermediate_iframe_close_callback field takes effect only in intermediate iframe mode

    It means the need to add intermediate Iframe Support JavaScript API as specified here.
    And Integrate One Tap via an Iframe as specified here.


    Other option to be notified about closing google one tap might be done in the prompt callback:

    google.accounts.id.prompt((notification) => {
        if (notification.isSkippedMoment() && notification.getSkippedReason() === 'user_cancel') {
            // do fallback logic
        }
    });
    

    You can have a look at the prompt documentation here for more functionalities.