Hi, Is there a way to generate api token from rest api? I need to automate db connection setup after generating api key. I have portal setup and got username and password but not able to find curl request to login using username and password. Though I see generateToken and CreateToken in openapi doc but seems its there for additional API Token.
If you want to 'preconfigure' a gateway with an API key, you can store one in the external resource collection, as mentioned in the post @Sfenwick linked:
Note that this same principle can be applied a layer higher. If you want to preconfigure a gateway connection - you can do the exact same thing (move a configured resource to the external collection) but with your configured DB connection.
You’ll want to POST against /data/api/v1/api-token/generate. This will return an object which contains a key and hash.
{
"key": "ABC",
"hash": "DEF"
}
You’ll then need to POST against /data/api/v1/resources/ignition/api-token, and include the hash from the previous request within the config.settings object.
{
"name": "MyNewAPIKey",
"collection": "core",
"enabled": true,
"description": "",
"config": {
"profile": {
"type": "basic-token",
"secureChannelRequired": false,
"securityLevels": [
{
"name": "Authenticated",
"description": "Represents a user who has been authenticated by the system.",
"children": []
}
],
"timestamp": 1755186044603
},
"settings": {
"tokenHash": "DEF"
}
}
}