课程: Python Essential Libraries
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
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…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。