随着微服务访问安全性的提高,服务之间调用会进行token校验,
而这个token大都数是放在header上,那怎么获取呢?
feign调用添加token
@RequestHeader
这个注解就行了
@PostMapping(value = "/v20160818/sms/sendInterfaceTemplateSms/{accountID}",headers = {"Authorization=111111"})
//如果是数据是固定的,那可以用这个注解,@Headers({"Content-Type: application/json;charset=utf-8;","Accept: application/json","Authorization:111111"})
//@Headers({"Content-Type: application/json;charset=utf-8;","Accept: application/json"})
//如果是动态的,可以使用@RequestHeader
Object sendMes(@RequestHeader("Authorization") String token, @PathVariable("accountID") String accountId, @RequestParam("sig") String sig, @RequestBody Map<Object,Object> sendMes);