From the course: Python Essential Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using authentication

Using authentication - Python Tutorial

From the course: Python Essential Libraries

Start my 1-month free trial

Using authentication

- [Instructor] Not all web services are free. Some of them require you to authenticate before you can use them, and there are several different types of authentication. The Requests library supports several kinds of authentication right out of the box. And there's an extension mechanism that you can use to add your own auth types if you need to. Now, in this example, I'm going to demonstrate two of these methods, the basic and digest authentication. So let's go ahead and open up the auth_start file in the editor, and I've imported the Requests library, and I've defined two variables, user and passwd, and I've set the values to theuser and thepass. So for this example, again, I'm going to use the httpbin service, which has an endpoint where you can test basic authentication. So let's go ahead and define that URL. And that is https, and that's httpbin.org. And I'm going to show basic-auth, and then the way that you…

Contents