code: public Login login(TokenResult token, String username, String password,
        String domain) throws Exception {
      username = encode(username);
      if (domain != null) {
        domain = encode(domain);
      }
      Api apiResult = null;
      // depends on MediaWiki version see
      // https://test2.wikipedia.org/w/api.php?action=help&modules=clientlogin
      if (this.isVersion128()) {
        Map<String, String> lFormData = new HashMap<String, String>();
        lFormData.put("lgpassword", password);
        lFormData.put("lgtoken", token.token);
        if (domain != null) {
          apiResult = getActionResult("login",
              "&lgdomain=" + domain + "&lgname=" + username, null, lFormData);
        } else {
          apiResult = getActionResult("login", "&lgname=" + username, null,
              lFormData);
        }
        // apiResult = getActionResult("clientlogin", "&lgname=" +
        // username+"&loginreturnurl="+this.siteurl, null, lFormData);
      } else {
        password = encode(password);
        if (domain != null) {
          apiResult = getActionResult("login", "&lgdomain=" + domain + "&lgname="
              + username + "&lgpassword=" + password, token, null);
        } else {
          apiResult = getActionResult("login",
              "&lgname=" + username + "&lgpassword=" + password, token, null);
        }
      }
      Login login = apiResult.getLogin();
      userid = login.getLguserid();
      return login;
    }
docs: second step of login process
  
  @param token
  @param username
  @param password
  @param domain
  @return
  @throws Exception