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

小程序 文章 2020-09-03 15:41 1268 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群

相关文章
关于微信小程序云开发调用api返回内容问题?
小程序复制链接地址能解析出url吗?
未知原因违反小程序流量主广告组件规范,广告展示关闭30天,求具体原因?
为什么我的数组总是乱序?
scroll-view做滑动导航,点击初始页面导航始终是第一个,只能点击隐藏后面的导航切换?
随便看看
微信公众号免300认证教程 4953
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4070
小程序广告组件通过审核,但是小程序内没有显示广告? 4151
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8014
问题? 7252
如何快速搭建抽奖助手小程序(无需代码知识) 5035
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 5989
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5507
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5204
如何解决渲染层网络错误Failed to load media? 16559