How to get an Amadeus Access token for API use

Having recently gone through the process I thought I would share my experience of how to gain a bearer token for the Amadeus API

The Amadeus API generally is easy to use with primarily GET requests but obtaining the authorization token is a little more difficult

Those trying to do this from App connect are likely to have problems as some of the API parameters are camel case so will be converted to lower case by app connect. In practice I would strongly recommend NOT using App connect API calls anyway as this would lead to your APi Key and API Secret being exposed to public viewing.

So the Amadeus Authorization guide can be found here

Looking at the cURL example

curl \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
https://test.api.amadeus.com/v1/security/oauth2/token \
-d "grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"

We see this is a POST call with 1 header

"Content-Type: application/x-www-form-urlencoded"

and 3 form Inputs

"grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"

where {client_id} and {client_secret} are the parameters provided from your Amadeus Account App definition

Send to the end point

https://test.api.amadeus.com/v1/security/oauth2/token

So these parameters are easily added to the API.
NOTE This has to be set to data type FORM

As this is a POST action, we are unable to Fetch a schema however Amadeus provides a sample schema to process

{
    "type": "amadeusOAuth2Token",
    "username": "foo@bar.com",
    "application_name": "BetaTest_foobar",
    "client_id": "3sY9VNvXIjyJYd5mmOtOzJLuL1BzJBBp",
    "token_type": "Bearer",
    "access_token": "CpjU0sEenniHCgPDrndzOSWFk5mN",
    "expires_in": 1799,
    "state": "approved",
    "scope": ""
}

So click on Define API Schema

image

Open the schema processing window

Paste in the sample schema and click process to import the schema

image

The schema will be imported.

image

Save it

That’s the setup complete

The API access_token and other associated information is then available through the server connect picker

image

The access_token is valid for 30 minutes and can be used with subsequent API calls and is used in the format

Bearer {{access_token}}

p.s. Big thanks to Serhat, @s.alpaslan for his assistance with this

Community Page
Last updated: