Amadeus API返回401客户端凭据无效 [英] Amadeus api return 401 client Credentials are invalid

查看:113
本文介绍了Amadeus API返回401客户端凭据无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Amadeus api返回 401客户端凭据无效。请检查下面的代码。我在符号字符串中包括了符号 []

Amadeus api returns 401 client Credentials are invalid. Please check the code below. I included symbols [ and ] into credential strings.

// here xxxxx are placeholders for real credentials (strings)
Amadeus amadeus = Amadeus.builder("[xxxxxx]","[xxxxxx]")
                    .setHostname("test").setHost("test.api.amadeus.com").setSsl(true).setLogLevel("debug").build();

//HttpHandler sh = new HttpHandler();

//FlightDestination[] des = sh.FlightDest();
//id = sh.id();

try {

    FlightDestination[] destination1 = amadeus.shopping.flightDestinations.get(Params.with("origin", "LON"));


    id = destination1[0].getOrigin();
    name = destination1[0].getDestination();
    email = destination1[0].getType();
}catch (ClientException e)
{
    id=e.getMessage();

}catch (NetworkException e)
{
    id = e.getMessage();

}catch (NotFoundException e)
{
    id = e.getMessage();
}catch (ServerException e)
{
   id =  e.getMessage();
}catch (ParserException e)
{
    id = e.getMessage();
}catch (ResponseException e)
{
    id = e.getMessage();
}


推荐答案

您不需要 [] ,您需要用本指南

您可以使用Java SDK查找示例此处此处

You can find examples using the Java SDK here and here.

Amadeus amadeus = Amadeus.builder("API_KEY", "API_SECRET").build();


/* Find cheapest destinations from London */

FlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params.with("origin", "LON"));

System.out.println(flightDestinations[0]);

这篇关于Amadeus API返回401客户端凭据无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆