Consuming HTTP Services in Python Transcripts
Chapter: Accessing authenticated HTTP services
Lecture: Concept: Adding authentication to requests
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Now you've seen how to use requests
0:04
to access restricted authorization requiring services,
0:09
so what we have to pass is that authorization header with the basic value
0:13
set to the basic c4 encoded version of username:password,
0:18
but remember, it's not encrypted, it's just obscured,
0:21
so how does this work, of course, everything more or less is the same,
0:25
other than the authentication, so we import request, we come up with the url,
0:28
we try to do a get against the service and we saw oh 401, not so amazing,
0:33
401 is you didn't log in, you are unauthorized, right,
0:37
so we just go and set the auth as a tuple, username,password,
0:43
and then ta- da, everything is 200 ok.