公众号配置服务器url报token验证失败?
发布于 4 年前 作者 ezheng 9402 次浏览 来自 官方Issues

我发现很多人遇到过类似问题,可是并没有很好的解答。我现在也碰到了类似的问题。

我的公众号wxcca50471fde16891  

我的服务器https://service-qrrcrg0b-1302863908.bj.apigw.tencentcs.com/release/test

我使用的token是zpf7879jess322

我的Python代码:

def main_handler(event, context):

    TOKEN='zpf7879jess322'

    data = event['queryString']

    signature = data['signature']

    timestamp = data['timestamp']

    nonce = data["nonce"]

    echo = data["echostr"]

    if not signature or not timestamp or not nonce:

        return ''

    

    tmp_str = "".join(sorted([TOKEN, timestamp, nonce]))

    tmp_str = hashlib.sha1(tmp_str.encode('UTF-8')).hexdigest()

    if tmp_str == signature:

        return echo

    else:

        return ''


我用Postman模拟了测试,看到echostr已经正确返回了,可就是无法验证通过。

求助!

回到顶部