从我的带有Bearer Auth令牌的代码中调用Airport&City Search amadeus自助服务API时获取403禁止的异常

问题描述 投票:0回答:1

我正在从Spring Boot应用程序中调用没有JAVA SDK的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
1个回答
0
投票

您正在使用http代替URL的https

© www.soinside.com 2019 - 2024. All rights reserved.