Authenticating with the server
When connecting to the API service, you must authenticate with the system server before executing any commands. You can authenticate in either of the following ways.
Authenticating with a user name and password
Issue the login command with the user name and password for a valid system user account as follows:
login userName password
The user name and password are verified against the user account database.
Authenticating with a token
To avoid entering an account password into a script or application, you can use an authentication token instead. Authentication tokens are generated in the console (click System > API Tokens). An authentication token represents a user account and has a unique ID that scripts can use to access the API.
Issue the login command with the authentication token as follows:
login 4e666e90-e838-4d22-b08b-4bd958f09a97
This method lets the script authenticate as the user represented by the token and to access the system with those permissions.
In the console, you can create a token and set it to expire automatically at a certain date, you can disable it, or you can revoke it.
To create an authentication token
- Click the System tab.
- From the Manage menu on the left, select API Tokens.
- On the right after the list of existing tokens, click New Token.
- From the User menu, select the user account to use for API requests.
- For Expiration Date, click the Show Calendar icon and select the date when the token should expire.
- For Expiration Time, select the time when the token should expire.
- Click Create to create the API token.
The new token appears in the list of API tokens.