getSetting获取不到scope.userInfo的授权信息?
发布于 5 年前 作者 chaoliang 7586 次浏览 来自 问答

按照文档中的示例代码写法(https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html#示例代码)在今天发布上去后,代码仍走了getUserInfo( <button wx:else open-type=“getUserInfo” bindgetuserinfo=“getUserInfo”> 授权</button>的逻辑,但是用户授权后,通过getSetting又获取不到scope.userInfo的授权信息,调用wx.getUserInfo时,返回err_code:-12007,errMsg:getUserInfo:fail scope unauthorized。

微信版本:iOS 8.0.2,基础库:2.16.0

2 回复

返回值中只会出现小程序已经向用户请求过的权限。

调用 wx.getSetting 前确认已经使用 <button open-type="getUserInfo" /> 请求过用户信息权限。

【另外: 开发版 & 体验版 scope.userInfo 调整将于 4月13日 对齐,统一返回 true】

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

pc微信暂不支持wx.getUserProfile,可以参考示例代码进行兼容

https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html#%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81

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

回到顶部