code: @Override
      void doLogin(String authUrl, final Callback<TokenInfo, Throwable> callback) {
          if (window != null && window.isOpen()) {
              callback.onFailure(new IllegalStateException("Authentication in progress"));
          } else {
              window = openWindow(authUrl, height, width);
              if (window == null) {
                  callback.onFailure(new RuntimeException(
                          "The authentication popup window appears to have been blocked"));
              }
              // Workaround to check if the user has closed the auth window,
              // since neither the onclose and onunload events work the expected way in this scenario
              window.setFinished(false);
              new Timer() {
                  @Override
                  public void run() {
                      if (window.hasFinished())
                          cancel();
                      if (!window.isOpen()) {
                          window.setFinished(true);
                          callback.onFailure(new RuntimeException("User has closed the authentication window."));
                          cancel();
                      }
                  }
              }.scheduleRepeating(300);
          }
      }
docs: Get the OAuth 2.0 token for which this application may not have already been granted access, by displaying a
  popup to the user.