RestTemplate 请求
@Autowired private RestTemplate httpRestTemplate; String code= request.getParameter("code"); URI url = new URI("http://10.20.60.107:8088/ssoserver/moc2/token"); // 参数拼装 LinkedMultiValueMap<String, String> postParam = new LinkedMultiValueMap<String, String>() ; postParam.add("grant_type", "authorization_code"); postParam.add("client_id", "222"); postParam.add("client_secret", "45B6E9F1D9A4F10873EB7B2B9BC2CB9AEC11E6AF4ED50980734E62ABFDE91210"); postParam.add("redirect_uri", "http://10.20.60.107:8088/ssoserver/third/oauth/login/callback"); postParam.add("code", code); ResponseEntity<JSONObject> forEntity = httpRestTemplate.postForEntity(url, postParam, JSONObject.class); JSONObject object = forEntity.getBody(); String accessToken = object.getString("access_token");