在小程序工具清理掉所有缓存后再次发起用户授权请求仍然会发生系统错误问题?

小程序 文章 2020-09-03 15:41 1294 0 全屏看文

AI助手支持GPT4.0

在小程序工具清理掉所有缓存后再次发起用户授权请求仍然会发生系统错误问题?After the mini program tool clears all the caches, the system error will still occur if the user authorization request is initiated again?

在小程序工具清理掉所有缓存后再次发起用户授权请求仍然会发生系统错误问题?
        /* 获取用户信息 */        wx.getSetting({            success(res) => {                // 如果用户已经授权 scope.userInfo 这个 scope                if (res.authSetting['scope.userInfo']) {                    // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框                    console.log("用户已授权")                    wx.getUserInfo({                        success(res) => {                            console.log("用户信息", res)                            }                        }                    })                } else { // 向用户发起授权请求                    console.log('向用户发起授权请求 scope.userInfo')                    wx.authorize({                        scope'scope.userInfo',                        success(suc) {                            console.log("用户已授权", suc                        },                        fail(err) {                            console.log("无法授权", err)                        },                        complete(c) {                            console.log("授权函数执行", c)                        }                    })                }            }        })

提示如下错误信息

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

截图

此时,只能通过用户主动去点击授权按键才会调出授权页面,但是就做不到首次打开小程序主动调出授权页面的要求了

/ * get user information * / wx.getSetting ({success: (RES) = > {/ / if the user is authorized scope.userInfo This scope if( res.authSetting ] scope.userInfo '] {/ / authorized, OK Call getUserInfo directly to get the nickname of the avatar without pop-up console.log (user authorized) wx.getUserInfo ({                        success: (res) => {                             console.log (user information), Res)}}}}} else {/ / issue authorization request to user console.log ('initiate authorization request to user scope.userInfo ')                      wx.authorize ({                        scope: ' scope.userInfo ',                        success(suc) {                             console.log (user authorized, suc},                         fail(err) {                             console.log (unable to authorize, ERR)},                         complete(c) {                             console.log (authorization function execution), (c)}}}}}}) the following error message is displayed“ authorize:fail System error, error code: - 12007, "Scope unauthorized" screenshot: at this time, the authorization page can only be called up by clicking the authorization button actively by the user. However, it is not possible to open the applet to call up the authorization page for the first time

回答:

citizen four:

谢邀,必须用户主动触发授权,不能强制,即使你设置了强制,审核也不会通过

王志鹏:

现在不是只能用户点击才能引导去授权 不能主动弹授权框了

村上植树:好的感谢
村上植树:

由于项目需要用户开启小程序后检测如果没有授权则自动拉起授权页面,目的也是尽量避免相关功能无法使用,但是已经无法自动拉起授权了,那么只能是引导用户去授权,在原来调用授权的地方修改成对话框的形式

                    console.log('向用户发起授权请求 scope.userInfo')                    wx.showModal({                        title'小贴士',                        content'如果要体验完整的功能,需要点击获取头像昵称来授权小程序使用哦',                        showCancel: false,                        confirmText'已知悉',                        success (res) {                            // ...                        }                     })


也只能想到这种方法了,如果有更好的方法也可继续在底下评论,感谢大家百忙之中的回复

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
微信小程序有没有一个可以读取聊天记录的接口?当然是使用者同意检索自己的聊天记录,
小程序是否有那种一次性授权后,后面都能长期收到服务通知的功能?
如何将通过条件查询得到的res中以某一字段为关键字遍历出来的数据赋值给新的数组?
没有找到哪里可以修改绑定公众号管理员?设置与开发,人员设置,修改功能在哪里?
云数据库在查询数据为空时会直接报错,怎么处理?
随便看看
问一下:设置页面里是空白的,该怎么弄? 301
最新版本的获取手机号接口的微信版本到底是什么? 611
反复跳转进入一个小程序A后跳回上个小程序B,直接打开小程序A后发现之前由小程序B传递的参数不丢失? 298
能否提供某个用户是否在某个群的接口? 296
小程序 wx.navigateBack 返回上一级 带入图片参数 上一级 无法渲染在页面上? 385
为什么 在开发者工具上能拿到 函数本身的 命名, 但是 在真机上 不行 。为啥? 311
汉字与数字样式不一? 295
TypeError: Cannot read property 'userinfo' of und? 555
商户与小程序费率不同导致的支付失败 404
我需要在视频号中接入小程序,有谁能帮到我啊? 306