Working with APIs and writing web clients can be a tricky business. Different APIs have different types of authorization, authentication, and protocol. We'll explore the http.Client structure object, work with OAuth2 clients and long-term token storage, and finish off with GRPC and an additional REST interface.
By the end of this chapter, you should have an idea of how to interface with third-party or in-house APIs and have some patterns for common operations, such as async requests to APIs.
In this chapter, we will cover the following recipes:
- Initializing, storing, and passing http.Client structures
- Writing a client for a REST API
- Executing parallel and async client requests
- Making use of OAuth2 clients
- Implementing an OAuth2 token storage interface
- Wrapping a client in added functionality and function composition ...