比如一键登录手机号,仅前端验证,后端不做验证,这应该是不安全的。如何通过后端来请求云函数,调用获取手机号的接口,现在调用会提示缺少参数realName,可是一键登录只需要获取手机号,不需要realName啊。
后端获取一键登录手机号的流程应该是怎样的?
云函数日志如下:
2026-07-21 14:32:08.562 [verify][SYSTEM][INFO][0a4b07f917846155285373790220] reserve_instance_start: reserveFunctionInstance start
2026-07-21 14:32:08.563 [verify][SYSTEM][INFO][0a4b07f917846155285373790220] reserve_instance_end: reserveFunctionInstance success; instanceName=de982ca9-456b-41b3-8592-dc2e05856663 ip=10.75.9.32
2026-07-21 14:32:08.563 [verify][SYSTEM][INFO][0a4b07f917846155285373790220] call_function_start: call function start
2026-07-21 14:32:08.565 [verify][SYSTEM][INFO][0a4b07f917846155285373790220] user_code_execution: de982ca9-456b-41b3-8592-dc2e05856663,version: aa9bc0f0
2026-07-21 14:32:08.570 [verify][USER][INFO][0a4b07f917846155285373790220] execute: de982ca9-456b-41b3-8592-dc2e05856663,event : {
path: '/',
httpMethod: 'POST',
headers: {
'accept-encoding': 'br,deflate,gzip,x-gzip',
'content-length': '313',
'content-type': 'application/json',
service: 'verify',
'sofa-rpcid': '0',
'sofa-traceid': '0a4b07f917846155285373790220',
sofa_head_method_name: '/getphone',
'user-agent': 'Apache-HttpClient/4.5.13 (Java/17.0.5)',
'x-djy-uuid': '3fddddf-f226-4ac3-bf77-5e44e2c734da',
'x-faas-context-bindconfigs': '{"NEED_AUTH":"false","NEED_SIGN":"false"}',
'x-faas-context-binddomain': 'env-003323566x1.dev-hz.cloudbasefunction.cn',
'x-faas-context-bindpath': '/getphone',
'x-faas-runtime-call-context': '{"appId":"2021005412354518696374","traceId":"0a4b07f917846155285373790220","rpcId":"0.1.2","requestId":"6446454221-9988-441b-b541-60f935d5d4b5","eventType":"http"}',
'x-faas-source-type': 'httpDefault',
'x-forwarded-for': '118.100.165.5',
'x-forwarded-proto': 'https',
'x-real-ip': '118.100.165.5',
'x-stream-request-id': '28486553-6630-4ee4-8def-785d0b276f4f',
'x5-uuid': '3fe65415-f226-4ac3-bf77-5e44e2c734da'
},
queryStringParameters: {},
body: '{\n' +
' "provider": "univerify",\n' +
' "appid": "LxV8YC655988PQdN1",\n' +
' "openid": "000gtc_996ac65224422699e25602a61",\n' +
' "access_token": "bm0xZmM1OWYwNTJmNDQ0YzcwOTY5YjRiNWVhY2ZiZWRhZnwxMDcxfDN8djN8M3wyMWIyYjY4MzIwZTI5MjdiYTcxYmFkNmE3MjRkZDE3Y3x8WXo2Y0Y2alkzbng2cFBXWkUwVTkwUlA3SlcyZUhvbjlYTWR0aFRUK3ZlWT0K"\n' +
'}',
isBase64Encoded: false
}
2026-07-21 14:32:08.570 [verify][USER][INFO][0a4b07f917846155285373790220] execute: de982ca9-456b-41b3-8592-dc2e05856663,$ { options: { provider: 'univerify' } } uniVerifyManager
2026-07-21 14:32:08.639 [verify][USER][WARN][0a4b07f917846155285373790220] execute: de982ca9-456b-41b3-8592-dc2e05856663,Error: 缺少参数: realName
at j.throwError (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:7927)
at j.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8462)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async $.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8759)
at async Proxy.<anonymous> (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:9086)
at async exports.main (/var/task/code/index.js:9:18)
at async We (/var/task/code/index.js:2:86679)
at async Je (/var/task/code/index.js:2:86929)
at async FetchEventPearl2.handleRequest (/var/task/index.js:62628:17)
at async Container.dispatchHttpRequest (/var/task/index.js:68654:17)
2026-07-21 14:32:08.639 [verify][SYSTEM][INFO][0a4b07f917846155285373790220] user_code_execute_exception: de982ca9-456b-41b3-8592-dc2e05856663,a [Error]: 缺少参数: realName
at j.throwError (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:7927)
at j.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8462)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async $.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8759)
at async Proxy.<anonymous> (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:9086)
at async exports.main (/var/task/code/index.js:9:18)
at async We (/var/task/code/index.js:2:86679)
at async Je (/var/task/code/index.js:2:86929)
at async FetchEventPearl2.handleRequest (/var/task/index.js:62628:17)
at async Container.dispatchHttpRequest (/var/task/index.js:68654:17) {
errMsg: '缺少参数: realName',
errCode: 4000,
code: 4000,
errSubject: 'uni-mobile2EleVerify',
forceReturn: false,
cause: undefined
}
2026-07-21 14:32:08.640 [verify][SYSTEM][ERROR][0a4b07f917846155285373790220] call_function_end: call function failed; err: {"code":"400","message":"error: 缺少参数: realName. stack: Error: 缺少参数: realName\n at j.throwError (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:7927)\n at j.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8462)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async $.request (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:8759)\n at async Proxy.<anonymous> (/var/task/code/@common_modules/uni-cloud-verify/index.js:1:9086)\n at async exports.main (/var/task/code/__index.js:9:18)\n at async We (/var/task/code/index.js:2:86679)\n at async Je (/var/task/code/index.js:2:86929)\n at async FetchEventPearl2.handleRequest (/var/task/index.js:62628:17)\n at async Container.dispatchHttpRequest (/var/task/index.js:68654:17)"}
1***@qq.com
- 发布:2026-07-21 15:25
- 更新:2026-07-21 15:25
- 阅读:25
0 个回复