DEVASC Exam QuestionsBrowse all questions from this exam

DEVASC Exam - Question 465


Refer to the exhibit. A developer creates a Python script to query a REST API by using an HTTP GET request. The remote server will authorize the request only if it includes HTTP Basic Auth parameters. The username is admin and the password is devnet123. Which line of code needs to be placed on the snippet where the code is missing?

Show Answer
Correct Answer: A

To make an HTTP GET request including HTTP Basic Auth parameters, the 'requests.get' function can directly accept the 'auth' parameter with a tuple containing the username and password. Therefore, the correct line of code is 'requests.get(url, auth=('admin', 'devnet123')).

Discussion

5 comments
Sign in to comment
peterbuzaOption: A
Jun 12, 2024

HTTPBasicAuth can be used once the it is imported: from requests.auth import HTTPBasicAuth In the other case A is working

kymoniOption: A
Oct 10, 2024

Option C has a typo, as there has to be a comma between username and password. Option A is correct too, it's a short version of HTTPBasicAuth. https://requests.readthedocs.io/en/latest/user/authentication/

LukeJones
Jun 5, 2024

C - needs base62 encoding

kymoniOption: C
Oct 10, 2024

We're importing the whole "requests" library, therefore we can use HTTPBasicAuth

daniii89
Feb 5, 2025

its not : its , so A correct

StewartJOption: C
Jan 20, 2025

confirmed via documentation C