-
Book Overview & Buying
-
Table Of Contents
Python Network Programming Techniques
By :
In the previous chapter, you learned how to specify header fields for a request. But if we are sending multiple requests to the same API, and thus require each of these requests to have the same authentication information, we will have to pass the headers dictionary on every single request. While we could do this, it requires additional effort and is very prone to errors since we might forget to pass the headers in one of our requests. To make our life easier and our code more maintainable, the requests module provides us with a way of storing header fields between requests by creating a Session object, and then setting the headers on it. Let's see how we can use such a Session object to specify the headers required for authenticating against the Meraki Dashboard API, and then use a GET request to retrieve all the organizations associated with the user this token belongs to.
Open your code editor...