Skip to content

System generated token API

  • Here, we can get the token of the API_user and the application_user(database user).
  • API user token used to set the permission of each API.
  • The application user means the end user who will use the application.

Get token api authorization

  • By default getToken api is public.
  • When settings are available with authTokenInfo array, it is not public otherwise it is public.
  • when value in secret provided for authTokenInfo, it has no impact on getToken system api.

Request Method: POST

URL

/api/system-api/user-path/token

Request payload API_user

  • Get the token of API Maker's API_user.
1
2
3
4
5
6
7
{
    "authTokenType": "AM",
    "authTokenAM": {
        "u": "USER_NAME",
        "p": "USER_PASSWORD"
    }
}

Request payload application_user

  • Get a token of API Maker's database user(application user).
{
    "authTokenType": "AM_DB",
    "authTokenAMDB": {
        "instance": "INSTANCE_NAME",
        "database": "DATABASE_NAME",
        "collection": "COLLECTION_NAME",
        "usernameColumn": "USER_NAME_COLUMN",
        "passwordColumn": "USER_PASSWORD_COLUMN",
        "u": "USER_NAME",
        "p": "PASSWORD"
    }
}

Get token using global object 'g'.

Get token api authorization

  • By default getToken api is public.
  • When settings are available with authTokenInfo array, it is not public otherwise it is public.
  • when value in secret provided for authTokenInfo, it has no impact on getToken system api.
1
2
3
4
5
6
7
await g.sys.system.getToken({
    "authTokenType": "AM",
    "authTokenAM": {
        "u": "USER_NAME",
        "p": "USER_PASSWORD"
    }
});
  • Get Token of database_user (application user).
await g.sys.system.getToken({
    "authTokenType": "AM_DB",
    "authTokenAMDB": {
        "instance": "INSTANCE_NAME",
        "database": "DATABASE_NAME",
        "collection": "COLLECTION_NAME",
        "usernameColumn": "USER_NAME_COLUMN",
        "passwordColumn": "USER_PASSWORD_COLUMN",
        "u": "USER_NAME",
        "p": "PASSWORD"
    }
});

API Response

1
2
3
4
5
6
7
8
9
{
    "success": true,
    "statusCode": 200,
    "data": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
        "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
        "expires_in": 10800
    }
}