Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【求助】uni.authorize 授权失败问题 #4987

Open
xjj210130 opened this issue Jun 16, 2024 · 1 comment
Open

【求助】uni.authorize 授权失败问题 #4987

xjj210130 opened this issue Jun 16, 2024 · 1 comment

Comments

@xjj210130
Copy link

xjj210130 commented Jun 16, 2024

请教一下,我使用如下代码
getUserInfo() {
var that = this;
uni.authorize({
scope: 'scope.userInfo', // 需要获取用户信息权限
success() {
// 用户同意授权
// 在授权成功后,再调用 uni.login 获取登录凭证
uni.login(
{ //获取到用户信息
provider: 'weixin',
success: (res => {
console.log('res-login', res);
//获取到code
that.code = res.code;
//请求登录接口
if (res.errMsg == 'login:ok')
{
uni.request({});
}
});}),
fail(authErr) {
// 用户拒绝授权,无法进行后续操作
uni.showLoading({ // 展示加载框
title: authErr.errMsg,
});
}

使用上述代码在电脑上测试,是没有问题,能够弹出授权小窗。 发布到微信公共平台上(体验版本), 则出现授权失败。fail scope unautorize。(模拟器调试正常使用,真机运行体验版报错。)
使用HBuilderX开发工具,ios系统体验。请问如何修改。
是配置的问题还是代码的问题呢?
再次感谢

@xjj210130
Copy link
Author

再请教一个问题, 微信小程序在真机上运行,开启调试模式,调用函数uni.login正确返回,关闭调试模式则返回失败,请问这是什么原因导致的?配置问题吗?谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant