Consuming HTTP Services in Python Transcripts
Chapter: Accessing authenticated HTTP services
Lecture: Concept: Authenticated requests with Python 3's urllib.requests
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let's look at the concepts behind authenticated basic auth request with urllib,
0:05
so again, we import urllib.request, this is the Python 3 version,
0:10
we have our url, and what we did is globally, one time we ran this code,
0:15
we said we want to set up a password manager,
0:18
so an http password manager with default realm and then,
0:22
we came along and added a password, no realm register the base url,
0:27
and said kennedy and super_lockdown, those are the username and the password,
0:31
and we created an http basic auth handler with that password manager,
0:35
and then we created an opener based on that handler,
0:40
and finally, we installed that opener,
0:42
and then any time there was a request going to that url through urllib,
0:46
it used this authenticated http basic auth handler that we had registered here.
0:51
We compose this and globally install it and it's done, so that is kind of nice,
0:58
but, it seems like there should be a simpler way to do this huh?