越王够贱
越王够贱
  • 发布:2020-12-14 00:10
  • 更新:2020-12-30 13:54
  • 阅读:2219

uniapp 微信登陆返回 40029 这个问题怎么解决?

分类:uni-app
                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);  
            });

uniapp输出日志:
00:07:16.707 获取code成功了:{"scope":"snsapi_userinfo","state":"wechat_sdk_dcloud_weixin_oauth","code":"013FX10w3N3QtV23WG0w3O8xEn2FX10b","lang":"zh_CN","country":"CN","target":{"id":"weixin","description":"微信","authResult":null,"userInfo":null}}

后台输出请求地址以及参数:
https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx528a8d3814bf5cd9&secret=0ad1d8047ec7e2db1703a821ec76d8d5&code=013FX10w3N3QtV23WG0w3O8xEn2FX10b&grant_type=authorization_code
--------------token:
后台返回输出:
{"errcode":40029,"errmsg":"invalid code, hints: [ req_id: d.GFGzyFe-RqISWa ]"}

2020-12-14 00:10 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com

楼主解决了吗?

  • 越王够贱 (作者)

    解决了 code 之前弄错了

    2021-04-25 13:08

  • jetbn

    回复 6***@qq.com: 怎么一个解决的?

    2021-07-12 09:51

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