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
--expiresflag to change the validity of a token. But you cannot go abovemaxTokenValiditythough you can increase it in your xo-server's config.Example:
xo-cli --createToken --expiresIn 90d https://XOA.company.lan admin password
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login