【发布时间】:2020-08-23 18:50:32
【问题描述】:
我在没有 JAVA SDK 的情况下从 Spring Boot 应用程序调用 amadeus 自助服务 API。 在第一次调用中,我通过调用授权 API 成功获取了 access_token。现在,如果我调用 Airport & City Search,则使用该 access_token,我会收到此响应。
{
"errors": [
{
"code": 38197,
"title": "Forbidden",
"detail": "Access forbidden",
"status": 403
}
]
}
我在请求标头中将 access_token 作为不记名令牌传递。下面是我的代码。
public String getCityList(String keyword) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(authToken);
HttpEntity<String> entity = new HttpEntity<String>(headers);
String url = "http://test.api.amadeus.com/v1/reference-data/locations?subType=AIRPORT,CITY&keyword=" + keyword
+ "&page[limit]=5";
String body = restTemplate.exchange(url, HttpMethod.GET, entity, String.class).getBody();
return body;
}
邮递员也可以使用相同的令牌。
我错过了什么吗?
提前致谢。
【问题讨论】:
标签: spring-boot oauth-2.0 resttemplate bearer-token amadeus