'How to detect the "closed_by_user" event via the new "Google 3P Authorization JavaScript Library API"

I'm currently using the Google Sign-In JavaScript Platform Library for web. Via the grantOfflineAccess() function I request access to scopes from the users Google account with ux_mode: 'popup'.

auth2.grantOfflineAccess().then(
  response => {
    // response handling 
  },
  error => {
    // error handling
  },
)

Currently I'm able to detect if the popup is closed without authorization, because the error callback is called with this data:

{
  error: "popup_closed_by_user"
}

As Google is discontinuing this Sign-In API I'm migrating to the new Google 3P Authorization JavaScript Library

As part of the migration, I have modified the authorization flow to code like this:

google.accounts.oauth2.initCodeClient({
  client_id: '[...].apps.googleusercontent.com',
  fetch_basic_profile: false,
  ux_mode: 'popup',
  scope: '[...]',
  callback: response => {
    // handle google feedback
  },
}).requestCode()

As the docs state, the callback can have the parameters code, scope, state, error, error_description, error_uri and I expected it to be the equivalent of the previous callbacks, but it does not seem to be called for the popup_closed_by_user event.

Unfortunately, I was also not able to find an alternative callback.

Is someone aware wether the popup_closed_by_user event can be detected with the new library?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source