Search code examples
google-identity-toolkit

Gitkit - popupMode and signInSuccess callback do not work well together


I'm using popupMode: true on my Sign In page, and have a signInSuccess callback function on my Widget page:

var config = { 
    ...
    callbacks: {
        signInSuccess: function(tokenString, accountInfo,
            opt_signInSuccessUrl) {
            console.log(JSON.stringify(accountInfo));                
            return true;
        }
    },
    ...
}

My function gets called, and the user gets signed-in in the original window, but the widget popup window does not close.

Is this a defect or am I missing something?


Solution

  • Yeah this behavior has been changed for popups when signInSuccess is provided. There were problems with the old behavior. The idea here is that when callback is provided, the developer wants to handle that on their own. The page is still closed automatically when no callback is provided. In your case you will need to close manually. You can add this snippet before you return true:

    if (window.opener) {
      window.close();
    }