curl -X POST ^
-H "Content-Type: application/json; charset=utf-8" ^
-H "X-AVOSCloud-Application-Id: t4od8nbs5csq6y2cc5s1bc7a00kw4qf8wwz4ob1iixkxdbuk" ^
-H "X-AVOSCloud-Application-Key: mdo9v35updy8rd9dlm760qgao61cx1tje2aoewps5qzuqokd" ^
-H "X-AVOSCloud-Session-Token: 33in7ba411h7bo7r4ksr5jo36" ^
-d "{}" ^
https://leancloud.cn/1.1/functions/getUserInfo
已经avoscloud deploy和avoscloud publish了,可是执行上面的curl脚本的时候会出现错误
{"code": 401, "error": "Unauthorized."}
但在本地的时候测试是正常的,也就是将https://leancloud.cn换成本地http://localhost:3000的时候是正常返回JSON数据的
不清楚到底哪里出现了问题,官方文档中说的是APPKEY和APPID不匹配,但也不应该本地能运行,服务器不能运行呀。
而且webHost网站,无论是本地还是服务器上都是能正常打开的,不知道哪里出现了问题,以下是云函数的源码,希望好心人帮忙找找茬
@engine.define
def getUserInfo():
currentUser = User().get_current()
if currentUser == None:
raise LeanEngineError(1001, 'Login required.')
else:
UserDetail = Object.extend('UserDetail')
query01 = Query(UserDetail)
query01.equal_to('User', currentUser)
userDetail = query01.first()
objectId = currentUser.id
createdAt = currentUser.created_at.strftime('%Y-%m-%d %H:%M:%S')
updatedAt = currentUser.updated_at.strftime('%Y-%m-%d %H:%M:%S')
username = currentUser.get('username')
email = currentUser.get('email')
mobilePhoneNumber = currentUser.get('mobilePhoneNumber')
emailVerified = currentUser.get('emailVerified')
mobilePhoneVerified = currentUser.get('mobilePhoneVerified')
sessionToken = currentUser.get('sessionToken')
NickName = userDetail.get('NickName')
QQ = userDetail.get('QQ')
Avatar = userDetail.get('Avatar')
AvatarUrl = Avatar.url
AvatarThumbnailUrl = Avatar.get_thumbnail_url(width = '64', height = '64')
Sex = userDetail.get('Sex')
result = { \
"objectId" : objectId, \
"createdAt" : createdAt, \
"updatedAt" : updatedAt, \
"username" : username, \
"email" : email, \
"mobilePhoneNumber" : mobilePhoneNumber, \
"emailVerified" : emailVerified, \
"mobilePhoneVerified" : mobilePhoneVerified, \
"sessionToken" : sessionToken, \
"NickName" : NickName, \
"QQ" : QQ, \
"AvatarUrl" : AvatarUrl, \
"AvatarThumbnailUrl" : AvatarThumbnailUrl, \
"Sex" : Sex \
}
return json.dumps(result)