Skip to main content

Connecting to Fleet API

As mentioned in intro

The process of authentication is similar for both Realtime and Batch API.

Authentication

We use a token based auth system. In order to generate a token

Steps:
1: Contact Fleet API team at may mobility for provisioning an account
2: Options to generate a token:

  • Follow AWS documentation for generating a token using client credentials here

  • Use postman to generate the token

  • Use the code sample(JS/TS) below to generate a token in your program

//  AWS COGNITO constants
export const COGNITO = {
base64Token : 'provided-by-fleet-api-team',
bodyParams : {
'grant_type': 'client_credentials',

'client_id': 'provided-by-fleet-api-team',
'client_secret': 'provided-by-fleet-api-team',
'scope': 'provided-by-fleet-api-team'
},
url: 'provided-by-fleet-api-team'
}

function getToken(){
fetch(COGNITO.url,
{
method: 'POST',
mode: 'cors',
headers : {
'Access-Control-Allow-Origin':'*',
'Authorization': `Basic ${COGNITO.base64Token}`,
'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
},
body : new URLSearchParams(COGNITO.bodyParams)
}
)
.then((response) => response.json())
.then((data) => {
console.log(data.access_token)
});
}

3: Pass the token while connecting to the APIs

  • Realtime API
    Pass it as a parameter in the url
domain?token=access_token_here&...
  • Batch (Rest Endpoints) API
    Pass it as a Bearer token in the Authorization Header
'Authorization': `Bearer access_token_here`

*Note: All connections are encrypted.

List of Data Topics Available