Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smack XMPP error while creating new user: forbidden - auth

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

like image 798
Suvitruf - Andrei Apanasik Avatar asked Oct 31 '22 04:10

Suvitruf - Andrei Apanasik


1 Answers

Solution:

step1:

enter image description here

step2:

enter image description here

step3:

enter image description here

after doing all these three steps run your program u will be able to register a new user on ejabberd server.

like image 79
singh.indolia Avatar answered Nov 15 '22 05:11

singh.indolia