划不来
划不来
  • 发布:2024-06-19 14:13
  • 更新:2024-06-19 17:50
  • 阅读:320

一键登录调用云函数,走catch回调,无法进入云函数内部,报错Error: The signature we calculated is:

分类:uniCloud

一键登录,调用云函数,走catch回调,无法进入云函数'getPhoneNumber内部,我这是真机调试,并不是打包环境。但是开通一键登录功能的时候,添加应用,需要填写证书签名,签名使用的是云端证书打包。报错Error: The signature we calculated is:.

不知道这个报错和那个证书签名是有没关系

uniCloud.callFunction({  
                    name: 'getPhoneNumber',  
                    data: {  
                        'access_token': res.authResult.access_token,  
                        'openid': res.authResult.openid  
                    }  
                })  
                .then(res => {  
                    // 登录成功 关闭一键登录弹框  
                    console.log('登录成功',res)  
                    closePhoneLoginOption()  

                    // 按需调用 登录接口获取token和其他信息  
                })  
                .catch(err => {  

                    console.error('云函数调用失败',err)  
                    closePhoneLoginOption()  
                })
2024-06-19 14:13 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

你在运行这个项目期间切换过服务空间吗?试试删除基座重装,再切换一次服务空间看看行不行

  • 划不来 (作者)

    好像关联过unicloud,当时发现打包不行,然后直接删除了uniCloud文件夹,重新创建unicloud的。那你说的删除基座重装,是什么意思,不懂,再删除uniCloud文件夹吗

    2024-06-19 16:07

  • 划不来 (作者)

    刚刚又把uniCloud文件夹删除了,重新绑定关联,弹出一些文件内容对比合并,处理后,还是这个报错

    2024-06-19 16:21

1***@qq.com

1***@qq.com - 菜鸟zyy

云函数有问题

  • 划不来 (作者)

    怎么说,哪里

    2024-06-19 16:20

  • 划不来 (作者)

    兄嘚,说话说一半

    2024-06-19 16:22

1***@qq.com

1***@qq.com - 菜鸟zyy

创建好云空间需要关联, 云函数里面的配置项有没有问题呢,

  • 划不来 (作者)

    关联了。原函数代码:'use strict';

    exports.main = async (event, context) => {

    //event为客户端上传的参数

    console.log('云函数',event)

    console.log('云函数',context)

    const res = await uniCloud.getPhoneNumber({

    // appid: 'UNIA58EAF0', // 替换成自己开通一键登录的应用的DCloud appid

    appid: context.APPID,

    provider: 'univerify',

    access_token: event.access_token,

    openid: event.openid

    })


    console.log('手机号码',res);  

    //返回数据给客户端
    return event

    };

    2024-06-19 16:34

划不来

划不来 (作者) - 我就是我

统一回答各位,问题解决了:如果项目单独封装uni.addInterceptor('request', {})根据官网介绍,callFunction内部会使用uni.request来发送请求,如果有对uni.request写拦截器务必准确区分要拦截的内容。由于我问了很多次,官方都不回答怎么区分,于是我去掉拦截器了,于是就不报错了,可以正常拿到手机号码。暂时想不到如果保留拦截器的话,应该怎么跟普通的request做判断区分。各位朋友,如果有想法,欢迎交流

要回复问题请先登录注册