tencentyun / wafer-session-server

Wafer - 企业级微信小程序全栈方案
https://github.com/tencentyun/wafer
Other
72 stars 45 forks source link

测试环境:调用鉴权服务失败:#40029 - WEIXIN_CODE_ERR #6

Closed enjoyfans closed 7 years ago

enjoyfans commented 7 years ago

本地部署之后(业务服务器,会话管理服务器都在本地localhost),调用微信服务器jscode2session之后报错 log如下: \mina_auth\index.php:13|{"returnCode":40029,"returnMessage":"WEIXIN_CODE_ERR","returnData":"","version":1,"componentName":"MA"}

这是怎么回事? 微信小程序客户端使用客户端示例Demo和qcloud-weapp-client-sdk。 小程序已经有appId,没有起名,没有发布,仅仅是在编码测试阶段,小程序使用http方式登录会话。 是因为http调用么?必须使用https方式?

var host = 'localhost:8080/com.qcloud.weapp.demo'; // 登录地址,用于建立会话 //loginUrl: https://${host}/login, loginUrl: http://${host}/login,

    // 测试的请求地址,用于测试会话
    //requestUrl: `https://${host}/user`,
    requestUrl: `http://${host}/user`,

    // 测试的信道服务地址
    //tunnelUrl: `https://${host}/tunnel`,
    tunnelUrl: `http://${host}/tunnel`,
enjoyfans commented 7 years ago
  1. 本地tomcat安装ssl 参考https://tomcat.apache.org/tomcat-9.0-doc/ssl-howto.html#Configuration

  2. 登录https://mp.weixin.qq.com/ 微信公众平台,生成AppSecret(小程序密钥),然后更新会话服务器db(cauth),设置小程序ID,和密钥 update cAppinfo set secret='生成的密钥' where appid='你的小程序ID'; 执行完毕后,#40029 - WEIXIN_CODE_ERR 错误不再出现。