Is there way to create/generate api token?

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.

You can see api’s in screenshot attached.

You have tagged this Ignition 8.1, the API is part of 8.3, there will be no tokens generated for 8.1

Hey David, I have updated the tag for 8.3. I didn’t find the existing tag so created new. Are you aware of the API with user creds?

This may be of some help if you’ve not seen it yet

2 Likes

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.

2 Likes

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"
        }
    }
}
3 Likes