报错信息 Error: [INVALID_CUSTOM_LOGIN_TICKET] environment not match
客户端代码
const auth = uniCloud.auth()
const userInfo = await auth.getUserInfo()
console.log(userInfo)
uniCloud.callFunction({
name:'user_login',
data:{
uuid: userInfo.uuid
}
}).then(res => {
console.log(res.result)
const auth = uniCloud.auth()
auth.signInWithTicket(res.result).then(() => {
// 登录成功
console.log('登录成功')
})
}).catch(err => {
console.log(err)
})
云函数代码
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ' event)
const auth = uniCloud.auth();
const ticket = auth.createTicket(event.uuid, {
refresh: 10 * 60 * 1000 // 每十分钟刷新一次登录态, 默认为一小时
});
//返回数据给客户端
return ticket
};
3 个回复
宇龙
相同问题
zarkk - alex
刚从阿里云转到腾讯云,结果也为这个云token困惑。兄弟解决了没有?
吐槽一下DD的文档,示例代码写的太不清楚了
DCloud_uniCloud_WYQ
https://uniapp.dcloud.io/uniCloud/cf-authentication?id=createticket