OAuth2 API Docs

Note: This is an advanced API and does not need to be used in most cases, apart from generating an auth token.

The OAuth2 API allows developers to manage everything that is related to authentication and authorization to the Cisco XDR platform. You can for example create an authorization token to be used in subsequent API calls, or integrate App grant flows.

Use Cases

  • Manage OAuth2 device grant routes.
  • Manage OAuth2 application grant flows.
  • Manage OAuth2 routes, including CSRF tokens.

How to use the API Docs

Use the interactive documentation to explore the OAuth2 API endpoints. Each request will have a complete description of all the required parameters and it also allows you to instantly try it out in the online console. Code templates are also provided for you to quickly build scripts.

In the interactive explorer, the Client ID and Client Secret has been pre-filled and will allow you to make read-only API requests. These credentials will allow you to get an Access Token, which will be stored for subsequent API requests and regenerated when it expires.

Note: The interactive documentation uses read-only credentials and the try it out feature will only work with GET and selected POSTrequests.

To try other OAuth2 API requests, go to https://visibility.amp.cisco.com/iroh/oauth2/index.html

Generate an Access Token

In the interactive API explorer, the Access Token is automatically generated using the pre-filled Client ID and Client Secret so you do not need to generate it yourself.

If you want to understand how the Access Token is generated from the Client ID and Client Secret credentials, take a look at the Authentication page.

For detailed instructions on how to use the interactive API documentation (or your own Python script), see the Getting Started page.

Download the OAuth2 OpenAPI Specification

Download the OAuth2 OpenAPI specification (OAS) file here.

Sample Code

Below is an example of how to use the OAuth2 API.

import json
import requests
import sys

# Your client id and password (See the Authentication page for more details.)
CLIENT_ID = 'client-...c72'
CLIENT_PASSWORD = 'MLOe_...-LPzh'

# Generate new access token
url = 'https://visibility.amp.cisco.com/iroh/oauth2/token'

headers = {
            'Content-Type':'application/x-www-form-urlencoded',
            'Accept':'application/json'
}

payload = {
            'grant_type':'client_credentials'
}

response = requests.post(url, headers=headers, auth=(CLIENT_ID, CLIENT_PASSWORD), data=payload)
print(response.text)

if response.status_code == 200:
    # convert the response to a dict object
    response_json = json.loads(response.text)

    # get the access token
    access_token = response_json['access_token']

    # get the scope of the token
    scope = response_json['scope']

    # get the duration that the token is valid
    expires_in = response_json['expires_in']