我正在尝试通过管理员帐户创建新用户。但我收到身份验证错误。
我尝试了类似this的答案,但没有帮助。

我用于创建新用户的代码:

AccountManager accountManager = AccountManager.getInstance(mConnection);

        if (accountManager.supportsAccountCreation()) {
            try {
                accountManager.createAccount(username, password);
            }

            catch (XMPPException ex) {
                LOG.info(ex.getMessage(), ex);
            }

        }
        else{
            LOG.error("Server doesn't support creating new accounts");
        }

而且我允许在配置中注册所有:
{access, register, [{allow, all}]}.

{access, register_from, [{allow, all}]}.

{mod_register, [
 ...
 {ip_access, [{allow, "127.0.0.0/8"},
              {deny, "0.0.0.0/0"}]},
 {access_from, register_from},
 {access, register}
]},

即使使用此配置,我也有错误:
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth
    at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:135)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:244)

P.S. Smack 4.1.0

最佳答案

解决方案:

step1:

java - 创建新用户: forbidden - auth时出现XMPP错误-LMLPHP
step2:

java - 创建新用户: forbidden - auth时出现XMPP错误-LMLPHP
step3:

java - 创建新用户: forbidden - auth时出现XMPP错误-LMLPHP

完成所有这三个步骤后,运行程序,您将能够在ejabberd服务器上注册新用户。

09-12 18:42