I'm trying to create new user via admin account. But I receive auth error. I tried answers like this, but it doesn't help.
My code for creating new user:
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");
}
And I allow registration for ALL in config:
{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}
]},
And even with this config i have error:
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
Solution:
step1:
step2:
step3:
after doing all these three steps run your program u will be able to register a new user on ejabberd
server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With