1***@qq.com
1***@qq.com
  • 发布:2023-11-01 10:31
  • 更新:2024-09-23 14:55
  • 阅读:401

uni-id外部系统联登报错Unexpected token / in JSON at position 109

分类:uniCloud
配置文件  
{  
"passwordSecret": "passwordSecret",  
"tokenSecret": "tokenSecret",  
"requestAuthSecret": "testSecret", // URL化请求鉴权签名密钥  
"tokenExpiresIn": 7200,  
"tokenExpiresThreshold": 600,  
"passwordErrorLimit": 6,  
"bindTokenToDevice": false,  
"passwordErrorRetryTime": 3600,  
"autoSetInviteCode": false,  
"forceInviteCode": false,  
"preferedAppPlatform": "app",  
"app": {  
"tokenExpiresIn": 2592000,  
"oauth": {  
"weixin": {  
"appid": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appid",  
"appsecret": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appsecret"  
},  
"apple": {  
"bundleId": "苹果开发者后台获取的bundleId"  
}  
}  
},  
"web": {  
"oauth": {  
"h5-weixin": {  
"appid": "微信浏览器内微信登录,所用的微信公众号appid",  
"appsecret": "微信公众号后台获取的appsecret"  
},  
"web-weixin": {  
"appid": "手机微信扫码登录,所用的微信开放平台(https://open.weixin.qq.com/)-网站应用的appid",  
"appsecret": "微信开放平台-网站应用的appsecret"  
}  
}  
},  
"mp-weixin": {  
"oauth": {  
"weixin": {  
"appid": "",  
"appsecret": ""  
}  
}  
},  
"mp-alipay": {  
"oauth": {  
"alipay": {  
"appid": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr",  
"privateKey": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr"  
}  
}  
},  
"service": {  
"sms": {  
"name": "应用名称,对应短信模版的name",  
"codeExpiresIn": 300,  
"smsKey": "短信密钥key,开通短信服务处可以看到",  
"smsSecret": "短信密钥secret,开通短信服务处可以看到"  
},  
"univerify": {  
"appid": "当前应用的appid,使用云函数URL化,此项必须配置",  
"apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965",  
"apiSecret": ""  
}  
}  
}
2023-11-01 10:31 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者)

云函数日志  
请求入参: {  
  "args": {  
    "path": "/externalLogin",  
    "httpMethod": "POST",  
    "headers": {  
      "sec-fetch-mode": "cors",  
      "content-length": "1171",  
      "referer": "http://localhost:8080/",  
      "sec-fetch-site": "cross-site",  
      "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",  
      "origin": "http://localhost:8080",  
      "uni-id-signature": "4139F2CF38642ED9699E7494002C61068089DEBCE962EE251E4BB56C9F268260",  
      "uni-id-nonce": "ycrepdkb5zs",  
      "x-forwarded-for": "172.28.211.99, 100.122.16.248",  
      "accept": "*/*",  
      "x-real-ip": "116.19.96.62",  
      "uni-id-timestamp": "1698805229145",  
      "host": "uni.***.com",  
      "content-type": "application/json",  
      "x-forwarded-by": "172.28.195.0:8000",  
      "cache-control": "no-cache",  
      "accept-encoding": "gzip, deflate, br",  
      "user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/118.0.0.0",  
      "sec-fetch-dest": "empty"  
    },  
    "queryStringParameters": {},  
    "isBase64Encoded": false,  
    "body": "{\"uniPlatform\":\"web\",\"clientInfo\":{\"SDKVersion\":\"\",\"appId\":\"***\",\"appLanguage\":\"zh-Hans\",\"appName\":\"**平台\",\"appVersion\":\"1.21.7\",\"appVersionCode\":\"110217\",\"browserName\":\"edge\",\"browserVersion\":\"118.0.0.0\",\"deviceId\":\"16988047893384601136\",\"deviceModel\":\"iPhone\",\"deviceOrientation\":\"portrait\",\"devicePixelRatio\":2.0000000596046448,\"deviceType\":\"phone\",\"hostLanguage\":\"zh-CN\",\"hostName\":\"edge\",\"hostTheme\":\"light\",\"hostVersion\":\"118.0.0.0\",\"language\":\"zh-CN\",\"model\":\"iPhone\",\"osName\":\"ios\",\"osVersion\":\"13.2.3\",\"pixelRatio\":2.0000000596046448,\"platform\":\"ios\",\"safeArea\":{\"left\":0,\"right\":375,\"top\":0,\"bottom\":667,\"width\":375,\"height\":667},\"safeAreaInsets\":{\"top\":0,\"right\":0,\"bottom\":0,\"left\":0},\"screenHeight\":667,\"screenWidth\":375,\"statusBarHeight\":0,\"system\":\"iOS 13.2.3\",\"ua\":\"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/118.0.0.0\",\"uniCompileVersion\":\"3.8.12\",\"uniPlatform\":\"web\",\"uniRuntimeVersion\":\"3.8.12\",\"version\":\"\",\"windowBottom\":0,\"windowHeight\":667,\"windowTop\":0,\"windowWidth\":375},\"appId\":\"__UNI__A5**\",\"params\":{\"externalUid\":\"146\"}}"  
  },  
  "requestId": "ac1cc3001698805229398100017"  
}  
[uni-id-co/ac1cc3001698805229398100017/3ms/ERROR] Invalid uni-id config file  
/tmp/function/@common_modules/uni-config-center/uni-id/config.json: Unexpected token / in JSON at position 109  
Error: Invalid uni-id config file  
/tmp/function/@common_modules/uni-config-center/uni-id/config.json: Unexpected token / in JSON at position 109  
    at _getOriginConfig (/tmp/function/@common_modules/uni-id-common/index.js:1:9231)  
    at x (/tmp/function/@common_modules/uni-id-common/index.js:1:8658)  
    at y (/tmp/function/@common_modules/uni-id-common/index.js:1:10441)  
    at _before (/tmp/function/index.obj.js:127:36)  
    at c (/tmp/function/__index.js:1:2718)  
    at exports.main (/tmp/function/__index.js:1:2821)  
    at Q (/tmp/function/index.js:1:24326)  
    at z (/tmp/function/index.js:1:25389)  
    at ae (/tmp/function/index.js:1:26359)  
    at runUserFunction (/code/index.js:98:229657)  
请求响应状态: fail  
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

看下是不是uni-id的配置里面带了注释

  • 1***@qq.com (作者)

    请问URL化请求鉴权签名 报错 uni-id-illegal-request 这个怎么解决

    2023-11-01 11:17

  • 1***@qq.com (作者)

    class Sign {

    constructor(requestAuthSecret) {

    this.requestAuthSecret = requestAuthSecret

    }


    getSignature(params, nonce, timestamp) {

    const paramsStr = this.getParamsString(params)

    const signature = CryptoJS.HmacSHA256(

    ${this.requestAuthSecret}${nonce},

    ${timestamp}${paramsStr}

    ).toString(CryptoJS.enc.Hex)


    return signature.toUpperCase()  

    }


    getParamsString(params) {

    return Object.keys(params)

    .sort()

    .filter(item => typeof params[item] !== 'object')

    .map(item => ${item}=${params[item]})

    .join('&')

    }

    }

    2023-11-01 11:18

1***@163.com

1***@163.com - 暂无简介

如果修改过 'uni-config-center' 文件

把对应的 config.json 中的注释去掉即可

1***@qq.com

1***@qq.com

没有注释了还是错误
Error: [UserId]: Invalid uni-id config file
/tmp/function/@common_modules/uni-config-center/uni-id/config.json: Unexpected token / in JSON at position 182

要回复问题请先登录注册