Gathole
Gathole

Reputation: 932

Register an user on XMPP server using xmpppy library

I want to implement a chat application using xmpppy library. So when the user is done with registration post that I want to create a user on XMPP server for the same user.

Upvotes: 2

Views: 855

Answers (1)

Gathole
Gathole

Reputation: 932

So here is the mistake what I was doing and after reading couple of blogs and codes I was able to register a user fro remote client

this is what I was doing to register a user

import xmpp

conn = xmpp.Client(ipaddress)
conn.connect((ipaddress,5222), secure=0)
conn.auth(user,passwd,sasl=1) # Admin user
conn.sendInitPresence()

xmpp.features.register(conn, "<vhost>", {'username': 'satish', 'password': 'password'})

And I was getting following error

<iq from='localhost' to='[email protected]/7193009741450550736425172' id='1534' type='error'>
    <query xmlns='jabber:iq:register'>
        <username>satish</username>
        <password>password</password>
        <name>satish</name>
    </query>
    <error code='403' type='auth'>
    <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
    </error>
</iq>

So I searched and found a post which says ejabberd.cfg file need to be changed from {access, register, [{deny, all}]}. to {access, register, [{allow, all}]}.

Under mod_register from {access, register} to {access_from, register}

service ejabberd restart

and tried again

xmpp.features.register(conn, "<vhost>", {'username': 'satish', 'password': 'password'})

Finally! It registered a new user

Upvotes: 4

Related Questions