收藏
回答

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

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

回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    2021-04-06

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


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


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


    2021-04-06
    有用
    回复
  • Baiye
    Baiye
    2021-04-06

    <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("未授权");
                  },
                });
              }
            },
          });
        },
    
    2021-04-06
    有用
    回复
登录 后发表内容
问题标签