The following code sample can be copied and executed from any command-line interface that includes the cURL library.
Note
In this sample, line breaks are added for readability. Remove these line breaks before you paste the code sample into your command-line tool.
curl -qgsSkH --no-progress-bar --header "Authorization: Basic dGVzdDp0ZXN0" -D /cygdrive/c/tmp/auth.txt -F form=foo https://xxx.xxx.xxx.xxx:443/wsapis/v2.0.0/auth/login
This cURL sample includes the following options:
-q—This option specifies that thecurlrcconfiguration file will not be read or used. Although this is an optional setting, Trellix recommends that you include this option.-g—This option turns off the URL globbing parser. Although this is an optional setting, Trellix recommends that you include this option.-s—This option turns off the progress meter and error message. Although this is an optional setting, Trellix recommends that you include this option.-S—When used with the-soption, this option shows error messages if your cURL switch fails. Although this is an optional setting, Trellix recommends that you include this option.-k—This option explicitly allows cURL to perform insecure SSL connections and transfers. This allows you to test your SSL connection without installing a CA certificate.-H—This option allows you to specify a custom header with the--headerswitch.--no-progress-bar—This option suppresses the cURL download progress bar, which can interfere with the request.--header "Authorization: Basic dGVzdDp0ZXN0"—This custom header provides a base64-encoded user name and password to be used to authenticate with your appliance. In this example,dGVzdDp0ZXN0resolves to the user name:password key pair: test:test.-D /cygdrive/c/tmp/auth.txt—This file name and path include the response from your appliance. The contents of this file appear as follows:HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Wed, 15 Jan 2014 03:03:15 GMT X-FeApi-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Content-Length: 0 Content-Type: text/plain; charset=UTF-8-F form=foo— The-Foption and the subsequent empty form force the cURL tool to use the HTTP POST request.https://xxx.xxx.xxx.xxx:443/wsapis/v2.0.0/auth/login—The authentication request URL. Replace the IP addressxxx.xxx.xxx.xxxwith the actual IP address of your appliance.
Results
The auth.txt file is populated with the response data.