Adding new user to ejabberd through Smack android api

Sagar Nayak

I have installed ejabberd on my local server. This was then tested in spark for its functionality and it worked fine. Now I want to add a new user through the android app.

I tried adding a new user through spark and it worked fine. The fields I have given are uesrname, password, confirm password, server. But when I tried to do it using the smack api in the android app it gave the following error:

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth

I was using createAccount(), seen in the code I was using below, to create the new account in smack.

AccountManager accountManager = AccountManager.getInstance(conn1);

try {
    accountManager.createAccount("tryuser", "qwerty");
    Log.i("log", "created user successfully");
} catch (SmackException.NoResponseException e) {
    e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
    e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
    e.printStackTrace();
}

I have checked if it supports new account creation by supportsAccountCreation() and it returned true.

I have changed my register rule to allow all in ejabberd server. and i don't think it has any problem because i can create account from spark, but getting error in smack.

I have looked into the following SO questions related to this topic but no luck.

Does anyone have any suggestions on how to solve this?

Vikram

Please give a try with below -

AccountManager accountManager = AccountManager.getInstance(connection);
                try {
                    if (accountManager.supportsAccountCreation()) {
                        accountManager.sensitiveOperationOverInsecureConnection(true);
                        accountManager.createAccount("userName", "password");

                    }
                } catch (SmackException.NoResponseException e) {
                    e.printStackTrace();
                } catch (XMPPException.XMPPErrorException e) {
                    e.printStackTrace();
                } catch (SmackException.NotConnectedException e) {
                    e.printStackTrace();
                }

And you also need to set below in ejabberd.cfg (config file)

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

which means - In-band registration allows registration of any possible username. To disable in-band registration, replace 'allow' with 'deny'.

And in mod_register (module in same config file) please set below -

{access_from, register} 

& before that please check you are connected to XMPP server.

Probably this will resolve your issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Smack Android client fails to connect to ejabberd server

From Dev

Android Smack SSL/TLS connection to XMPP Ejabberd server with CA Certificate

From Dev

smack / ejabberd Connection Timeout

From Dev

Ejabberd can't register new user

From Dev

Adding products to a new sales quote through the Odoo API (Java)

From Dev

Block user in android using xmpp + smack + openfire

From Dev

Block user in android using xmpp + smack + openfire

From Dev

Sending and Receiving messages using Smack Api for Android

From Dev

Connecting with server using smack API in MainActivity android

From Dev

getting SocketTimeoutException while using smack 4.1.2 in android to connect to my ejabberd server

From Dev

getting SocketTimeoutException while using smack 4.1.2 in android to connect to my ejabberd server

From Dev

django - Adding a new user

From Dev

Adding new user and group

From Dev

Enroll new user in 2-Step verification through the Google API

From Dev

Enroll new user in 2-Step verification through the Google API

From Dev

Android - Framework to walk the user through the new version changes

From Dev

How to use Smack 4.2 for connecting to ejabberd?

From Dev

How to create chat room in ejabberd through rest api?

From Dev

How to create chat room in ejabberd through rest api?

From Dev

Retrieve user country through Facebook Android Graph API

From Dev

android: adding a new node

From Dev

Adding a new aspect with a User property

From Dev

Problem adding shell to new user

From Dev

Problem adding shell to new user

From Dev

What is the minimum required Android API level for Smack 4.1?

From Dev

How to send one to one message using smack API 4.1.0 android

From Dev

Looping through a groupby and adding a new column

From Dev

Adding items through navigation and storing in new context

From Dev

Adding items through navigation and storing in new context

Related Related

  1. 1

    Smack Android client fails to connect to ejabberd server

  2. 2

    Android Smack SSL/TLS connection to XMPP Ejabberd server with CA Certificate

  3. 3

    smack / ejabberd Connection Timeout

  4. 4

    Ejabberd can't register new user

  5. 5

    Adding products to a new sales quote through the Odoo API (Java)

  6. 6

    Block user in android using xmpp + smack + openfire

  7. 7

    Block user in android using xmpp + smack + openfire

  8. 8

    Sending and Receiving messages using Smack Api for Android

  9. 9

    Connecting with server using smack API in MainActivity android

  10. 10

    getting SocketTimeoutException while using smack 4.1.2 in android to connect to my ejabberd server

  11. 11

    getting SocketTimeoutException while using smack 4.1.2 in android to connect to my ejabberd server

  12. 12

    django - Adding a new user

  13. 13

    Adding new user and group

  14. 14

    Enroll new user in 2-Step verification through the Google API

  15. 15

    Enroll new user in 2-Step verification through the Google API

  16. 16

    Android - Framework to walk the user through the new version changes

  17. 17

    How to use Smack 4.2 for connecting to ejabberd?

  18. 18

    How to create chat room in ejabberd through rest api?

  19. 19

    How to create chat room in ejabberd through rest api?

  20. 20

    Retrieve user country through Facebook Android Graph API

  21. 21

    android: adding a new node

  22. 22

    Adding a new aspect with a User property

  23. 23

    Problem adding shell to new user

  24. 24

    Problem adding shell to new user

  25. 25

    What is the minimum required Android API level for Smack 4.1?

  26. 26

    How to send one to one message using smack API 4.1.0 android

  27. 27

    Looping through a groupby and adding a new column

  28. 28

    Adding items through navigation and storing in new context

  29. 29

    Adding items through navigation and storing in new context

HotTag

Archive