我的小程序嵌入uni-im;需要在服务端打通与uni-id的用户系统 。当前按照文档【 //https://doc.dcloud.net.cn/uniCloud/uni-id/cloud-object.html#external】的步骤进行配置
调试的报错:
{"success":false,"error":{"code":"InternalBizError","message":"no_matching_function_for_path /uni-id-co/externalRegister"}}
根据文档找不到解决方案:
访问链接是:https://fc-mp-ee363348-a386-41c7-8812-xxxxxxxx.next.bspapp.com/uni-id-co/externalRegister
我在小程序端:的cloudfunctions/common/uni-config-center/uni-id/config.json文件里
已经配置了 "requestAuthSecret": "", // URL化请求鉴权签名密钥
以下是我的java端代码
//外部系统联调-注册
//小程序端:已经在 cloudfunctions/common/uni-config-center/uni-id/config.json 配置requestAuthSecret 并上传云空间
String requestAuthSecret="qwertyuiop111asdzxcqwertyuiop111asdzxc";
String url = "https://fc-mp-ee363348-a386-41c7-8812-xxxxxxxx.next.bspapp.com/uni-id-co/externalRegister";
Map<String,Object> params = new HashMap<>();
params.put("externalUid","ab1234");
params.put("nickname","测试1");
params.put("username","ab1234");
params.put("avatar","https://d187uamsy6q6zw.cloudfront.net/2020/03/27/312bbb3f-7231-4083-8ed4-d941e814e3cd.jpg");
params.put("gender", 0);
Map<String,String> info = new HashMap<>();
info.put("uniPlatform", "web");
info.put("appId", "__UNI__A7315951");
Map<String,Object> data = new HashMap<>();
data.put("params",params);
data.put("clientInfo",info);
String nonce= RandomUtil.randomString(15);
long timestamp = System.currentTimeMillis();
Map<String,String> headers=new HashMap<>(3);
headers.put(UniConstant.HEADER_NONCE, nonce);
headers.put(UniConstant.HEADER_TIMESTAMP,String.valueOf(timestamp));
data.put("params",info);
data.put("uniIdToken","");
String signature = UniUtil.getSignature(params, nonce, timestamp, requestAuthSecret);
headers.put(UniConstant.HEADER_SIGNATURE,signature);
HttpRequest post = HttpUtil.createPost(url);
HttpResponse response = post.addHeaders(headers).body(JSONUtil.toJsonStr(data)).execute();
System.out.println(response.body());
//打印的还是 {"success":false,"error":{"code":"InternalBizError","message":"no_matching_function_for_path /uni-id-co/externalRegister"}}
4***@qq.com (作者)
嗯 没有URL化原因
2025-01-10 21:09