Skip to content

Get Access Token

Request URL

POST /auth/get-token

Description

This endpoint is used to obtain an authentication token from the server, as well as to set an expiration date and time for the token.

This request will result in a token generated by the server if successful. In all subsequent requests, the token will need to be added into the request headers as a key:value pair with the key name "x-connectfi-token":

"x-connectfi-token": "a long random string"

curl --location --request GET 'http://sample.com/sampleurl' \
--header 'x-connectfi-token: 2dImU5MSc4QCC5y3JJYp7A6cgZ2aNH6nyThjadS7k2kC42262YTedrOPMD9JglnsaR' \
--data-raw ''

Schema

Property table for auth/get-token

Property Description Required Schema
user user Yes aggregator user object

Property table for aggregator user object

Property Description Required Schema
login login Yes {
  "type": "string",
  "pattern": "^[0-9a-zA-Z_]+$",
  "minLength": 1,
  "maxLength": 36,
  "$id": "common-id"
}
password password Yes {
  "type": "string",
  "minLength": 1,
  "maxLength": 50,
  "$id": "common-password"
}
requestId requestId No {
  "type": "string",
  "pattern": "^((?![<>]).)*$",
  "minLength": 1,
  "maxLength": 32,
  "isNotOnlyWhitespace": true,
  "$id": "common-commonStr32Req"
}

Request Body

{ 
    "user" :{
        "login": "CONNECTFI_CLIENTID",
        "password": "CONNECTFI_PASSWORD"
    }
}

Snippet Examples

javascript

const axios = require('axios');
const data = { 
    "user" :{
        "login": "CONNECTFI_CLIENTID",
        "password": "CONNECTFI_PASSWORD"
    }
};
const config = {
  method: 'POST',
  url: '${CONNECTFI_BASE_URL}/auth/get-token',
  headers: {
    'Content-Type': "application/json"
  },
  data
};

let result;
try {
  result = await axios.request(config);
  if (result.status === 200) {
    console.log(JSON.stringify(result.data));
  }
} catch (err) {
  console.log({
    errCode: err.code,
    responseStatus: err.response && err.response.status,
    data: err.response && JSON.stringify(err.response.data)
  });
}

cURL

curl --location "CONNECTFI_BASE_URL/auth/get-token" --data "{ \"user\":{\"login\":\"CONNECTFI_CLIENTID\",\"password\":\"CONNECTFI_PASSWORD\"}}" --header "Content-Type: application/json" 

Successful Response Examples

200 GET-TOKEN SUCCESSFUL RESPONSE

HEADERS

Header Value
Content-Type application/json

REQUEST BODY

{ 
    "user" :{
        "login": "CLIENTID",
        "password": "123CLIENTID!"
    }
}

RESPONSE BODY

{
    "code": "0",
    "data": {
        "dtsExpireAt": "2023-11-02T16:02:40.123Z",
        "token": "3BZHhuj3lifdgzGBPRRdjo2ch1l5dXLZC1tcXPMYKgJ14RMKBD064H1iFIHb7Sc0oh",
        "type": "base",
        "tokens": [
            {
                "token": "3BZHhuj3lifdgzGBPRRdjo2ch1l5dXLZC1tcXPMYKgJ14RMKBD064H1iFIHb7Sc0oh",
                "type": "base"
            },
            {
                "token": "7tL3zIRf4fU6kpyLOz1b1T5swihGqn8EZpoMFofQNUzM46j7iZyyQ7fczhfMNMtZA0",
                "type": "confined"
            }
        ]
    },
    "requestId": "154b6f6078d011eeb5658f28ab5fe311"
}