exam questions

Exam 200-901 All Questions

View all questions & answers for the 200-901 exam

Exam 200-901 topic 1 question 146 discussion

Actual exam question from Cisco's 200-901
Question #: 146
Topic #: 1
[All 200-901 Questions]


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?

  • A. resp = requests.post(url, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
  • B. resp = requests.post(url, auth=(DNAC_USER, DNAC_PASSWORD)) token = resp.json ()['Token'] return token
  • C. resp = http.post(url, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
  • D. resp = http.post(url, auth=(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
nunyabeez
10 months ago
Selected Answer: A
I think this might be another trick question. The requests module allows a shorthand for basic auth that would normally render answer B to also be correct. If you don't specify HTTPBasicAuth, then the auth parameter automatically assumes it. However, there appears to be a typo in answer B where there's a space between json and (), which would cause an error.
upvoted 2 times
nunyabeez
10 months ago
See this link to confirm the shorthand for basic auth with the requests module. https://requests.readthedocs.io/en/latest/user/authentication/
upvoted 2 times
...
...
nospampls
1 year ago
Selected Answer: A
A because of requests and of auth=HTTPBasciAuth https://developer.cisco.com/docs/dna-center/#!api-quick-start/authentication
upvoted 1 times
...
macxsz
1 year, 5 months ago
Selected Answer: A
Shoul be A resp = requests.post(url, auth=HTTPBasicAuth(DNAC_USER, DNAC_PASSWORD)) token = resp.json()['Token'] return token
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...