From the course: Scripting for Testers

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Authentication

Authentication

- [Instructor] You've seen how easy it is to make API calls. You can now make calls to any public API, which is great. However, many APIs require some form of authentication if you want to access them. I don't want to get into all the details of API authentication in this video, but let's take a look at a few types that you might encounter and see how you can call APIs that use them. So the first type I want to look at is called basic auth. As the name implies, it's pretty basic. All you need to do is specify a username and password. So let's test this out with our gig tracker application. I've already got Python opened here and I've specified the base URL to our application. And once again, a reminder that your URL will be different than this. Let's start setting up a request. So I'll do a response to store what we get back, and then we'll do requests.get, and once again, we're going to use this base_url, and then we're going to do api/users on the end of it. But let's try, instead…

Contents