0

I recently tried implementing yowsup python client on my raspberry pi (running raspbian). I have downloaded all relevant libraries for yowsup and completed the 2 step registration process.

I took the sample layer.py and run.py files from the yowsup github to make a simple echo bot.

When I try to run the run.py I am met with the following error:

Any help is much appreciated!

python run.py
Traceback (most recent call last):
  File "run.py", line 20, in <module>
    stack.loop() #this is the program mainloop
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/stacks/yowstack.py", line 196, in loop
    asyncore.loop(*args, **kwargs)
  File "/usr/lib/python2.7/asyncore.py", line 216, in loop
    poll_fun(timeout, map)
  File "/usr/lib/python2.7/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/lib/python2.7/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/lib/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/network/layer.py", line 102, in handle_read
    self.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/network/layer.py", line 110, in receive
    self.toUpper(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
    self.processReceived()
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
    self.toUpper(oneMessageData)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive
    self.toUpper(payload)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/coder/layer.py", line 35, in receive
    self.toUpper(node)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/logger/layer.py", line 14, in receive
    self.toUpper(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive
    self.toUpper(protocolTreeNode)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 189, in receive
    s.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/axolotl/layer_receive.py", line 44, in receive
    self.toUpper(protocolTreeNode)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper
    self.__upper.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 189, in receive
    s.receive(data)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 125, in receive
    recv(node)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/auth/layer_authentication.py", line 81, in handleFailure
    raise AuthError(nodeEntity.getReason())
yowsup.layers.auth.autherror.AuthError: not-authorized
user1861013
  • 139
  • 8

1 Answers1

0

I recently had a very similar issue, and I believe the problem is that the tutorial is out of date. There are now three Axolotl layers you have to include in your stack, instead of just the one (see this commit).

Where your stack would have looked like this:

layers = (
    EchoLayer,
    YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                      YowAckProtocolLayer]), YowAxolotlLayer
) + YOWSUP_CORE_LAYERS

It now has to look like this:

layers = (
    EchoLayer,
    YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer,
                      YowAckProtocolLayer]), AxolotlReceivelayer, AxolotlSendLayer, AxolotlControlLayer,
) + YOWSUP_CORE_LAYERS

You'll need to add the following imports as well:

from yowsup.layers.axolotl import AxolotlSendLayer, AxolotlControlLayer, AxolotlReceivelayer

Please note that AxolotlReceivelayer has a lowercase 'L' in 'layer'. I think this was probably an oversight on the part of the Yowsup maintainers, since it's incongruous with the rest of their naming scheme. What I do is this:

from yowsup.layers.axolotl import AxolotlReceivelayer as AxolotlReceiveLayer

just so that I've got consistency in my code.

wimkeir
  • 65
  • 2
  • 9