Amadeus api return 401 client Credentials are invalid

最后都变了- 提交于 2019-12-14 04:13:53

问题


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();
}

回答1:


You don't need the [ ] and you need to replace them by the API_KEY and the API_SECRET that you get following this guide.

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]);


来源:https://stackoverflow.com/questions/53261094/amadeus-api-return-401-client-credentials-are-invalid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!