如果引入feign,会显得很臃肿,推荐使用 http组件来调用。
调用的时候需要用到认证,你可以通过secure的配置来指定这些接口是需要token还是basic认证还是其他的认证。
配置好之后再用http组件调用即可。
按照该文档方法进行了配置,一直提示
{"msg":"缺失令牌,鉴权失败","code":401,"data":null}
配置如下:
{"msg":"缺失令牌,鉴权失败","code":401,"data":null}
代码如下:
{"msg":"缺失令牌,鉴权失败","code":401,"data":null}
日志:
{"msg":"缺失令牌,鉴权失败","code":401,"data":null}
目前接口都能顺利调用通,但一直没用鉴权成功。
我晕,编辑好的咋个成这样~
配置:
#动态签名认证配置 sign: - method: ALL pattern: /dashboard/sign crypto: "sha1" - method: ALL pattern: /blade-business/taxrawdata/pull crypto: "sha1"
代码
// secure
Map<String, String> headers = new HashMap<>(); long timestamp = DateUtil.now().getTime(); String nonce = "223"; String signature = DigestUtil.sha1Hex(timestamp + nonce); headers.put("nonce", nonce); headers.put("timestamp", String.valueOf(timestamp)); headers.put("signature", signature); HttpRequest.get("http://localhost/blade-business/taxrawdata/pull") .log(LogLevel.BODY) .queryMap(queryMap) .cacheControl(CacheControl.FORCE_NETWORK) .addHeader(headers) .execute() .onResponse(responseSpec -> { if (responseSpec.isOk()) return ReturnT.SUCCESS; return new ReturnT(ReturnT.FAIL.getCode(), responseSpec.message()); });
日志:
org.springblade.core.http.Slf4jLogger : --> GET http://localhost/blade-business/taxrawdata/pull?endDate=20210622&startDate=20210619
org.springblade.core.http.Slf4jLogger : signature: 5e138fd57bd5f65faf01954d4740ef43ac3d0a5f org.springblade.core.http.Slf4jLogger : nonce: 223 org.springblade.core.http.Slf4jLogger : timestamp: 1624332240162 org.springblade.core.http.Slf4jLogger : User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 org.springblade.core.http.Slf4jLogger : --> END GET
错误信息
{"msg":"缺失令牌,鉴权失败","code":401,"data":null}
讨论(0)
-
网关默认会对Blade-Auth请求头进行校验


讨论(0)
官方新品
- 热议问题
-
强制有些sql查主库
1
-
报文加密后端加密后传给前端,前端解密发现long类型的数据精度丢失
1
-
iot后台通过feign调用不到服务
1
-
variables.scss的@use引入冲突
1
-
cloud版本远程调用提示file文件名不存在
1
-
BladeX-biz 新建module后,启动报错:Failed to determine suitable jdbc url
1
-
powerjob执行任务状态是等待Worker接收,如何解决通讯问题
1
-
框架4.4.0版本的,现有的功能有支持直接获取远程调用抛出的异常提示吗?
1
-
bladex自定义认证模块
2
-
fegin 远程调用如何传递 BladeUser 到远程?
1
扫一扫访问 Blade技术社区 移动端