exyclearsky
exyclearsky
  • 发布:2020-10-12 11:45
  • 更新:2022-07-20 22:21
  • 阅读:2409

微信登录报错40029

分类:uni-app

使用云函数微信登录时,报错Error: [login-by-weixin]: :errCode: 40029 | errMsg: invalid code, hints: [ req_id: KfFE4tNre-fJZVsA ],该怎么解决呢 ? 检查过了, appid和appsecret 已经配置 。

2020-10-12 11:45 负责人:无 分享
已邀请:
chenli

chenli

排查下,测试账号和线上账号的appid和appsecret是否弄混了。

比如:微信开发工具添加项目时填的是线上账号的appid,后台代码里请求openid的时候用的是测试账号的appid和appsecret。

越王够贱

越王够贱

楼主解决了吗? 我也碰到这个问题

                WXService.authorize((e)=>{  
                    console.log("获取code成功了:"+JSON.stringify(e));  
                    //plus.nativeUI.alert("获取code成功:"+JSON.stringify(e));  

                    // 文档: https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&lang=zh_CN  
                    uni.request({  
                        url: dSystemParam.dBasePath + 'data/account/wxlogin/', // 后端缓存access_token和refresh_token  
                        data: {code: e.code},  
                        method:'POST',  
                        header: {'content-type': 'application/x-www-form-urlencoded'},  
                        success: (res)=>{  
                            plus.nativeUI.alert("获取用户信息成功:"+JSON.stringify(res.data));  
                            //this.userInfo = res.data  
                        }  
                    });  
                });  

            }, function(e){  
                let data = JSON.stringify(e);  

                if(data.code == -2){  
                    this.$refs.uToast.show({  
                        title: '您已经取消登录,是否碰到什么问题?',  
                        type: 'error',  
                        icon : false,  
                        duration : 4000  
                    });  
                }  
                console.log(e);  
            });
迷糊K

迷糊K - 从Java入门的野生程序猿一枚

我也遇到了,小程序的微信登录code

该问题目前已经被锁定, 无法添加新回复