Refer to the exhibit.

A developer creates a script to obtain a list of devices by using the Cisco DNA Center API. The remote server authorizes the request only if an authentication token is supplied in the headers. A function named get_auth_token() must retrieve a valid token by using HTTP Basic Authentication. Which code must be added to complete the get_auth_token() function?
Correct Answer: A
To complete the get_auth_token() function in the script to obtain a valid authentication token using HTTP Basic Authentication, you need to use the requests library correctly. The correct approach involves using the requests.post() method with the HTTPBasicAuth function.
A: resp = requests.post(url, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
* Correct. This option uses requests.post() and HTTPBasicAuth properly. It retrieves the token from the JSON response.
B: resp = requests.post(url, auth=(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
* Incorrect. This option incorrectly passes the auth credentials as a tuple without HTTPBasicAuth.
C: resp = http.post(url, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
* Incorrect. http is not a valid method from the requests library.
D: resp = http.post(url, auth=(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
* Incorrect. This option uses http.post(), which is incorrect.
References:
* requests - HTTP for Humans
* Cisco DNA Center Platform