REST API token generation via curl
-
Is there a method available, or planned, to generate a REST API token via curl? My environment currently has tokens set to expire after 72 hours and regenerating it via xo-cli or pulling it through the web UI is an extra manual step.
Being able to run something similar to the below to generate and store a token would help with automating some tasks I am looking to do on a scheduled basis
curl --location 'https://XOA.company.lan/rest/v0/authorization/token' --data-urlencode 'grant_type=password' --data-urlencode 'username=admin' --data-urlencode 'password=P@$$w0rd'
-
Ping @julien-f
-
@dan89 Nope, there is no way to achieve that this time.
Why is it easier than
xo-cli --createToken https://XOA.company.lan admin password
? -
@julien-f some of the scripts I need to be run can't always run on the XOA appliance and need to be run on other Linux/Windows hosts so the output can be manipulated for use via other programs/methods.
Having a way to pass authentication through curl would give the ability to generate a token when not running scripts on the main XOA appliance.
-
-
@julien-f slightly off topic then, but is there a way to extend token expiration for a single user and not globally? Or to have a single user excluded from the global default?
-
@dan89 Yes, you can pass the
--expires
flag to change the validity of a token. But you cannot go abovemaxTokenValidity
though you can increase it in your xo-server's config.Example:
xo-cli --createToken --expiresIn 90d https://XOA.company.lan admin password