小程序登录后code 换取 session_key提示invalid code

发布于 7 年前作者 xujie8428 次浏览最后编辑 7 年前来自 ask

调用的URL如下:

https://api.weixin.qq.com/sns/jscode2session?appid=wxxxxxxxxxxx&secret=xxxxxxx&js\_code=003duLE40qNLNG1X9MC40HiPE40duLEV&grant\_type=authorization\_code

返回的响应是:

{

errcode”: 40029,

errmsg”: invalid code, hints: [ req_id: C9GKJa0445ns80 ]

}

首先确认code没有超过5分钟。这个是什么原因呢?

给的提示信息对于调试没用任何价值啊

5 回复
yang68
yang681 楼6 年前

看下是不是appid,secret弄错了

bwei
bwei2 楼6 年前

在IDE上不行,后来换到手机上试可以了。

xia65
xia653 楼6 年前

如果前端代码appid修改,但后台代码appsecret没修改的话,会报这个错。

guiying88
guiying884 楼6 年前

我也想知道怎么回事,一直不成功!!!!

yanshi
yanshi5 楼5 年前

我顶!!!!有谁碰到过这个问题吗?怎么解决的?