简体   繁体   中英

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.

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='gathole@xxx.xx.xx.xxx/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM