wechatpy icon indicating copy to clipboard operation
wechatpy copied to clipboard

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 1: invalid start byte

Open M2shad0w opened this issue 6 years ago • 3 comments
trafficstars

from wechatpy.enterprise.crypto import WeChatCrypto from wechatpy.exceptions import InvalidSignatureException log.info("%s, %s, %s, %s" % (msg_signature, timestamp, nonce, echostr)) crypto = WeChatCrypto(sToken, sEncodingAESKey, sCorpID)

echo_str = crypto.check_signature(
    msg_signature,
    timestamp,
    nonce,
    echostr
)

File "/miniconda2/envs/py3/lib/python3.6/site-packages/wechatpy/utils.py", line 87, in to_text return value.decode(encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 1: invalid start byte -->

问题描述 (Description)

企业微信接口认证

配置信息 (Environment/Version)

  • OS
  • Python 3.6

  • wechatpy 1.75

M2shad0w avatar Dec 13 '18 16:12 M2shad0w

run then demo, meet the same error https://github.com/jxtech/wechatpy/blob/90b509a1bc7271234e860ac0c5fdb816877d98b7/examples/echo-enterprise/app.py#L33

/base.py", line 46, in _decrypt
    xml_length = socket.ntohl(struct.unpack(b'I', content[:4])[0])
struct.error: unpack requires a buffer of 4 bytes

M2shad0w avatar Dec 14 '18 07:12 M2shad0w

Can you paste the related variable values?

messense avatar Dec 16 '18 08:12 messense

wework get url

[ERROR] 2018-12-13 23:59:08,824 Uncaught exception GET /v1/wework?msg_signature=26222fa66ca085c5ad701a23d3d37d8344c4607d&timestamp=1544716748&nonce=1545138129&echostr=OqUjj41N1Gq3Rf5xitOLynuQ1q%2FuQDuuuqw3oVR8L3pVcEZ0hnjfxAqQKr5XqdOz%2Bd6OKdaS2peZF9PgtjvY9w%3D%3D (127.0.0.1)

M2shad0w avatar Dec 17 '18 05:12 M2shad0w