Skip to content

Get token

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