【问题标题】:Getting 403 Forbidden exception while calling the Airport & City Search amadeus self service API from my code with Bearer Auth token使用 Bearer Auth 令牌从我的代码调用 Airport & City Search amadeus 自助服务 API 时出现 403 禁止异常
【发布时间】: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


    【解决方案1】:

    您正在使用http 而不是https 作为网址。

    【讨论】:

    • 感谢您指出这一点!!!尽管根据文档发送请求,但我很困惑为什么还有 403。
    猜你喜欢
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-09-13
    • 2021-07-10
    • 2017-04-15
    相关资源
    最近更新 更多