简体   繁体   中英

"must be str, not bytes" while trying to authenticate to xmpp server

My code is:

import xmpp

jabberid = "admin@mydomain.com"
password = "password"
receiver = "admin@mydomain.com"
message  = "hello world"

jid = xmpp.protocol.JID(jabberid)
connection = xmpp.Client(server=jid.getDomain())
connection.connect()
connection.auth(user=jid.getNode(), password=password,resource=jid.getResource())

I'm recieving this error:

 File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/eduardo/Desktop/adiconf/xmpp-sv/api/main/user/routes.py", line 33, in add
    connection.auth(user=str(jid.getNode()), password=str(password), resource=str(jid.getResource()))
  File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/client.py", line 228, in auth
    while self.SASL.startsasl=='in-process' and self.Process(1): pass
  File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/dispatcher.py", line 126, in Process
    raise _pendingException[0](_pendingException[1]).with_traceback(_pendingException[2])
  File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/dispatcher.py", line 304, in dispatch
    handler['func'](session,stanza)
  File "/home/eduardo/.local/share/virtualenvs/xmpp-sv-KIKvfzDF/lib/python3.6/site-packages/xmpp/auth.py", line 179, in SASLHandler
    self.DEBUG('Got challenge:'+data,'ok')
TypeError: must be str, not bytes

I'm using the xmpppy module, but I'm not sure why? as the params that I'm passing to connection.auth are all strings

You must decode data in 'auth' file in lib. This line must be looked like that.

data=base64.b64decode(incoming_data).decode()

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