为什么拿不到授权信息,而且清除授权后也不弹授权窗,每次调接口都是授权成功,而且获取的信息都是空!?

小程序 文章 2021-04-06 13:02 588 0 全屏看文

AI助手支持GPT4.0

为什么拿不到授权信息,而且清除授权后也不弹授权窗,每次调接口都是授权成功,而且获取的信息都是空!?Why can't I get the authorization information, and the authorization window does not pop up after clearing the authorization, every time the interface is adjusted, the authorization is successful, and the information obtained is empty! ?

为什么拿不到授权信息,而且清除授权后也不弹授权窗,每次调接口都是授权成功,而且获取的信息都是空!?

errMsg: "authorize:fail 系统错误,错误码:-12007,scope unauthorized

errMsg: " authorize:fail System error, error code: - 12007, scope unauthorized

回答:

社区技术运营专员-Jahozheng:

周知:getUserInfo 开发版 & 体验版 已对齐 getUserInfo 匿名表现,正式版将于 4月13日 正式对齐 getUserInfo 匿名表现。请开发者使用 getUserProfile 获取用户信息。


小程序登录、用户信息相关接口调整说明:https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801


Baiye:....原来改接口了啊,我说怎么之前能用,现在一直出错。。。。。
|G.XIAO|:
在最外层调用 wx.getSetting(),开发版本和体验版本获取不到 "scope.userInfo"如果在 wx.getUserProfile 成功回调里,调用wx.getSetting(),能拿到 "scope.userInfo",不过已经意思不大了因为wx.getUserProfile 需要用户才能触发


Baiye:

<button open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button>

getUserInfo() {      var that = this;      wx.showLoading({        title: "授权中...", //提示的内容,        mask: true, //显示透明蒙层,防止触摸穿透,      });      wx.getSetting({        success(res) {          console.log(res);          //信息授权          if (!res.authSetting["scope.userInfo"]) {            //未授权getUserInfo            wx.authorize({ scope: "scope.userInfo", success(res) {   console.log("授权成功"); //授权成功直接登录   // console.log(res);   that.userInfo = res.userInfo;   wx.hideLoading();   that.getUserLocation(); }, fail(err) {   wx.hideLoading();   console.log("授权失败");   console.log(err); },            });          } else {            //已授权            wx.getUserInfo({ success(res) {   // console.log(res);   console.log("已授权"); //授权就可直接登录   that.userInfo = res.userInfo;   wx.hideLoading();   that.getUserLocation(); }, fail(err) {   console.log("未授权"); },            });          }        },      });    },

-EOF-

AI助手支持GPT4.0