收藏
回答

消息推送配置-Token校验返回200302

{"base_resp":{"err_msg":"verify token fail","ret":200302}}


我把微信调用的请求信息打印出来,手动发送命令,返回的就是echostr的值,是字符串的

最后一次编辑于  2018-09-23
回答关注问题邀请回答
收藏

6 个回答

  • 社区技术运营专员-小柿子
    社区技术运营专员-小柿子
    2018-09-25

    你好,请确认下token正确以及有效是否正确

    2018-09-25
    赞同
    回复
  • SSRR
    SSRR
    11-15

    python连接,同问

    我甚至跳过验证,都提示失败??????

    import web
    import hashlib
     
    urls = (
        '/wx', 'Handle',
    )
     
    class Handle(object):
        def GET(self):
            try:
                data = web.input()
                if len(data) == 0:
                    return "hello, this is handle view"
                return data.echostr
            except Exception as Argument:
                return Argument
                 
    if __name__ == '__main__':
        app = web.application(urls, globals())
        app.run()

    {"base_resp":{"ret":200302,"err_msg":"verify token fail"}}

    请问官方到底是什么情况啊?你们文档是我看到现在写的最模糊的,各种问题

    11-15
    赞同 1
    回复
  • 杨仙僧
    杨仙僧
    08-09

    我python3.5

    # -*- coding: utf-8 -*-
    # filename: handle.py
     
    import hashlib
    import web
     
    class Handle(object):
        def GET(self):
            try:
                data = web.input()
                if len(data) == 0:
                    return "hello, this is handle view"
                signature = data.signature
                timestamp = data.timestamp
                nonce = data.nonce
                echostr = data.echostr
     
                token = "123" #请按照公众平台官网\基本配置中信息填写
                list = [token, timestamp, nonce]
                list.sort()
     
                list = [token, timestamp, nonce]
                list.sort()
                # python2.7
                # sha1 = hashlib.sha1()
                # map(sha1.update, list)
                # hashcode = sha1.hexdigest()
     
                # python3.x
                sha1 = hashlib.sha1()
                sha1.update(list[0].encode("utf-8"))
                sha1.update(list[1].encode("utf-8"))
                sha1.update(list[2].encode("utf-8"))
                hashcode = sha1.hexdigest()  # 获取加密串
     
                # python3.x
                # temp = ''.join(list)
                # sha1 = hashlib.sha1(temp.encode('utf-8'))
                # map(sha1.update, list)
                # hashcode = sha1.hexdigest()
                # print("handle/GET func: hashcode, signature: ", hashcode, signature)
                if hashcode == signature:
                    # print(echostr)
                    return echostr
                else:
                    return ''
            except Exception:
                return Exception

    后台看见200 ok,echostr也return了,依旧token验证失败

    08-09
    赞同 1
    回复
  • s天天😃
    s天天😃
    03-13

    经测试,文档中  “ 开发者通过检验signature对请求进行校验(下面有校验方式)。若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败。”  (https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319) ,所谓“原样返回echostr参数内容”,就是说直接把echostr写到应答包体中即可,不带任何格式即可成功,文档原文表述不清晰。成功的校验抓包如下:


    GET /shwx/api/callback?signature=67e14d2ed1f32698bab9ed7b673fab3f8ab7f902&echostr=382485513798135407&timestamp=1552460909&nonce=583572733 HTTP/1.0

    Host: gzh

    Connection: close

    User-Agent: Mozilla/4.0

    Accept: */*

    Pragma: no-cache


    HTTP/1.1 200 OK

    Date: Wed, 13 Mar 2019 07:08:29 GMT

    X-Application-Context: application:8083

    Content-Type: text/plain;charset=iso-8859-1

    Content-Length: 18


    382485513798135407




    03-13
    赞同
    回复
  • Bearny
    Bearny
    01-18

    同问

    01-18
    赞同
    回复
  • Kun
    Kun
    2018-09-25

    文档巨坑,说好原样返回的,我就按照返回字符串了,后面转成整型就校验成功了

    2018-09-25
    赞同
    回复 1
    • SSRR
      SSRR
      11-15
      不行啊,我int后还是验证失败
      11-15
      回复