Overview
Most requests to the Incydr API must be authenticated. This article describes the available API authentication methods and provides examples of their use.
Incydr Developer Portal
See the Developer Portal for more API documentation and resources. The portal provides:
- A single access point for documentation of methods for Incydr, including the REST API, Incydr SDK, and command-line interface (CLI)
- A single request URL for API calls to each cloud instance
- API reference documentation
Use the Developer Portal for your API needs as much as possible. APIs in the portal are the preferred way to integrate with Incydr. If you use APIs that do not appear on the Developer Portal, contact our Technical Support Engineers for guidance on the best way to integrate with Incydr.
- The examples in this article use curl, but the concepts apply to other tools that can be used to interact with the API.
Comparison of API authentication methods
The Incydr API offers the following authentication methods:
- Obtain a token with an API client (only applies to APIs in the Developer Portal): You obtain a temporary authentication token that is good for 15 minutes and use it to authenticate API requests.
- Use basic authentication (deprecated for APIs in the Developer Portal): You provide your username and password to authenticate each API request.
- Use basic authentication to obtain a token (deprecated for APIs in the Developer Portal): You obtain a temporary authentication token that is good for 30 minutes and use it to authenticate API requests.
The following table describes the advantages and disadvantages of each authentication method:
| Authentication method | Advantages | Disadvantages |
|---|---|---|
| Obtain a token with an API client |
|
|
|
Use basic authentication
|
Simple to use |
|
|
Use basic authentication to obtain a token
|
|
|
Obtain a token with an API client
To obtain a token, first create an API client.
Use basic authentication
To use basic authentication, include your Incydr username in the API request and supply your password when prompted.
curl -u "username" <request_url>/api/v1/Computer
Replace <request_url> with the URL of your Incydr environment (do not include the brackets in your request):
You can use basic authentication for any version 1 or 4 and later resource, and version 3's /auth/jwt resource.
Use basic authentication to obtain a token
Step 1: Get the token
- Include your username in a GET request to auth/jwt and supply your password when prompted.
curl -u "username" '
<request_url>/api/v3/auth/jwt?useBody=true'Replace
<request_url>with the address of your incydr environment (do not include the brackets in your request). The request URL you use in your authentication request depends on your Incydr cloud address.If your organization uses two-factor authentication for local users, you must also include a totp-auth header value containing the six- to eight-digit Time-based One-Time Password (TOTP) supplied by the Google Authenticator mobile app. (Sending the request without the TOTP displays the error message
TIME_BASED_ONE_TIME_PASSWORD_REQUIRED.) The example below includes a TOTP value of 424242.curl -u "username" -H "totp-auth: 424242" '
<request_url>/api/v3/auth/jwt?useBody=true' - From the reply, copy the value of the v3_user_token. In the example below, it is
eyJjdHki...txd546Eg{"data":{"v3_user_token":"eyJjdHki...txd546Eg"},"error":null,"warnings":null}
Step 2: Use the token in API requests
Include that token in API requests. For example:
tkn="eyJjdHki...txd546Eg" curl --header 'Authorization: Bearer '$tkn<request_url>/api/v1/User curl --header 'Authorization: Bearer '$tkn<request_url>/api/v3/org/<organizationID>/user curl -H 'Authorization: Bearer '$tkn<request_url>/api/v4/role/view
Replace <request_url> with the address of your Incydr environment (do not include the brackets in your request).
External resources
Related topics
- Authentication in the Incydr Developer Portal
- API clients
- incydr API resources
- Incydr API syntax and usage
- Sample uses of the Incydr API
- Tools for interacting with the Incydr2 API
Comments
Please sign in to leave a comment.