Similarly, the X-Random-Header that took up so much space is sent without being explicitly present. The API key authentication was attached to the HTTP call, even though we did not explicitly include it in the command. Then use the -session flag to give the session a name: When you make your first call, include the authentication, headers, and whatever else you want to send with every call. In either case, these get in the way of the rest of your API call. Session functionality is convenient when you pass API tokens in headers or as part of a request URL. Use the session functionality, so you don’t repeat your authentication. While the server must receive credentials fresh each time, HTTPie can store them to send on your behalf. This is repetitive and inconvenient.Īs an API client, HTTPie must abide by the API server’s rules. For example, if your API requests are to a cloud storage service, every request that accesses your account needs your credentials for that service. Every time you make an API request you must include any authentication credentials, even if you sent them in a previous request. By contrast, each API request stands on its own. Typical code-level approaches include modularization and similar abstractions. Meant to reduce repetition, DRY stands for Don’t Repeat Yourself. You may be familiar with the DRY principle in software development. That lets you focus on the bigger issues, like getting API authentication to work. The natural syntax keeps your head in your API development and your eyes out of man pages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |