问题点:客户端多次请求查询余额接口,前面几次都是可以成功返回余额不足,
多试几次后会返回:{"errcode":90010,"errmsg":"[signature] signature is invalid traceid: 33575907 rid: 638f127a-1354b11d-733ccc65"}
而且客户端每次调用服务器接口之前都会 wx.checkSession 校验session_key是否有效,并且每次校验返回都是有效的。
下面请求的session_key:ou+4NlDJeMTj1J86ku8nuA==
具体服务端打印的请求日志如下,下面日志里面请求的URL 的 access_token 用【123】替代,实际请求日志是线上access_token;只贴出了前一次成功下一次失败的日志。
【成功请求日志】
2022-12-06 17:59:20:264 [GetBalance]请求URL:https://api.weixin.qq.com/wxa/game/getbalance?access_token=123&signature=231a6cf2b42f9c46e90011f71694581f9635d009d37a4b0dcc46ceecea78e401&sig_method=hmac_sha256&pay_sig=c43f34418c1232d7f01e98250c173a3fc7b105d363c059283edb12e89816fb61
2022-12-06 17:59:20:264 [GetBalance]请求参数:{ "openid": "osyGm5SzCxTD9Snsv8MWT1DXWJoA", "offer_id": "1450044152", "ts": 1670320760, "zone_id": "1", "env": 1 }
2022-12-06 17:59:20:780 [GetBalance]查询余额返回值:{"errcode":0,"errmsg":"ok","balance":0,"present_balance":0,"sum_save":0,"sum_present":0,"sum_balance":0,"sum_cost":0,"first_save":true}
【失败请求日志】
2022-12-06 17:59:22:389 [GetBalance]请求URL:https://api.weixin.qq.com/wxa/game/getbalance?access_token=123&signature=b1e49f9199c897e48fa0a97f872eff1592f06a753c3ee676021bd8960fe5d3df&sig_method=hmac_sha256&pay_sig=30c528be81192fdcdf790b0dcb040aad4f053809c97a39997035017ab0334448
2022-12-06 17:59:22:389 [GetBalance]请求参数:{ "openid": "osyGm5SzCxTD9Snsv8MWT1DXWJoA", "offer_id": "1450044152", "ts": 1670320762, "zone_id": "1", "env": 1 }
2022-12-06 17:59:22:623 [GetBalance]查询余额返回值:{"errcode":90010,"errmsg":"[signature] signature is invalid traceid: 33575907 rid: 638f127a-1354b11d-733ccc65"}
请问解决了么
请教下,signature字段说明是个登录态签名,具体填什么信息呢,用户登录信息吗?
解决了嘛?
明确了应该是第三方SDK,会启动一个定时器去调用wx.login,导致我们session key失效
算法对,sessionkey参数也对,那就只可能是post_body不对应了,可能post过程中这个库增加了一些东西到post body? 可以客户端角度抓包看一下这个http请求的实际post body,是否和签名时一致。
我们下午打算在签名失败时,在回包里面回传post_body,帮助定位。
session_key:JPcfRMQUVtuXZWGUbrkO7w==
****************************微信小游戏回调访问****************************
2022-12-07 15:31:06:497 [GetBalance]请求URL:https://api.weixin.qq.com/wxa/game/getbalance?access_token=123&signature=88e127e30f2cb4886723adf724649b7f3664fe2a6dc76065f7e3a03a82dc2486&sig_method=hmac_sha256&pay_sig=9b4c357bfeef548cd4ccaac5220d03f12eed392b23924f13f1bee810d036baf0
2022-12-07 15:31:06:497 [GetBalance]请求参数:{"openid":"osyGm5SzCxTD9Snsv8MWT1DXWJoA","offer_id":"1450044152","ts":1670398266,"zone_id":"1","env":1}
2022-12-07 15:31:06:951 [GetBalance]查询余额返回值:{"errcode":0,"errmsg":"ok","balance":0,"present_balance":0,"sum_save":0,"sum_present":0,"sum_balance":0,"sum_cost":0,"first_save":true}
****************************微信小游戏回调访问****************************
2022-12-07 15:31:07:860 [GetBalance]请求URL:https://api.weixin.qq.com/wxa/game/getbalance?access_token=123&signature=9bfb82dc95972764d6b410452f1f591e9c10cc63ceb7b60bbf9f01381b278972&sig_method=hmac_sha256&pay_sig=6465ca1efa23956d9ad7914130b3b75558dda266b4da1ec3a124d21da6023dd2
2022-12-07 15:31:07:860 [GetBalance]请求参数:{"openid":"osyGm5SzCxTD9Snsv8MWT1DXWJoA","offer_id":"1450044152","ts":1670398267,"zone_id":"1","env":1}
2022-12-07 15:31:08:141 [GetBalance]查询余额返回值:{"errcode":90010,"errmsg":"[signature] signature is invalid traceid: 33561395, raw post_body(remove wrapped []): [{\"openid\":\"osyGm5SzCxTD9Snsv8MWT1DXWJoA\",\"offer_id\":\"1450044152\",\"ts\":1670398267,\"zone_id\":\"1\",\"env\":1}], base64_encoded_post_body: eyJvcGVuaWQiOiJvc3lHbTVTekN4VEQ5U25zdjhNV1QxRFhXSm9BIiwib2ZmZXJfaWQiOiIxNDUwMDQ0MTUyIiwidHMiOjE2NzAzOTgyNjcsInpvbmVfaWQiOiIxIiwiZW52IjoxfQ== rid: 6390413b-7e7ad000-7f8408dd"}