java 请求oss github api,认证是 使用token令牌添加到header中的方式,来做登录认证的:
public JSONArray getMilestoneList(String ossValue, String ossTaken) {
String OssUrl = "https://oss.domain.com/api/v3/" //设置请求头 HttpHeaders requestHeaders = new HttpHeaders();
String tokenValue = "token "+ossToken; requestHeaders.add("Authorization", tokenValue ); HttpEntity request = new HttpEntity(requestHeaders); //请求某个ossValue仓库的api数据 ResponseEntity<JSONArray> rss = restTemplate.exchange(ossBaseUrl + "repos/" + ossValue + "/milestones", HttpMethod.GET, request, JSONArray.class);//getForObject和getForEntity都不支持传入请求头参数。 if (!rss.getStatusCode().is2xxSuccessful()) { throw new OssAccessException(rss.getStatusCode().value(), rss.getBody().toString()); } return rss.getBody(); }
代码解析:标签:ossValue,github,String,登录,oss,api,请求,rss From: https://www.cnblogs.com/pingguomang/p/18397087
1.ossTaken的值从哪里来?
2.ossValue的值是什么?