The provided documentation outlines how to use Basic HTTP Authentication with the Cisco AMP API. The correct method involves encoding the client ID and API key in base64 format and then including them in the authorization header. However, in the given scripts, the use of the requests library’s auth parameter directly with the client ID and API key is also a valid method.
Option A correctly uses the requests library to make an API call with the client ID and API key. This method is supported and valid as per the documentation.
python
Copy code
import requests
amp_client_id = 'alb2c3d4e5f6g7h8i9j0'
amp_login_password = 'l0g1n_p@ssw0rd'
url = 'https://api.amp.cisco.com/v1/version '
request = requests.get(url,
auth=(amp_client_id, amp_login_password))
print(request.json())
Client ID and API Key: amp_client_id and amp_login_password are set with the values provided.
URL: The URL for the AMP API endpoint is correctly set.
GET Request: The requests.get method is used with the auth parameter that takes a tuple of the client ID and API key.
Response: The response is printed in JSON format.
Option B:
Does not use the auth parameter or a header for Basic Authentication, thus it will fail.
Option C:
Option D:
Incorrectly uses the auth parameter with a concatenated client ID and API key without specifying Basic Authentication in the header.
References: