macaroonbakery is a Python library that provides higher-level operations for working with macaroons, building upon the core `pymacaroons` library. It implements the httpbakery conventions, allowing for automatic gathering of discharge macaroons for third-party caveats. The library is currently at version 1.3.4 and, while listed as '2 - Pre-Alpha' on PyPI, shows recent activity on its GitHub repository, suggesting active maintenance.
pip install macaroonbakeryVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `macaroonbakery.httpbakery.BakeryAuth` to interact with a protected URL. It automatically manages the acquisition and storage of macaroons using a `RequestsCookieJar`. The `PROTECTED_URL` should be replaced with an actual endpoint that uses macaroon-based authentication. The first request might trigger a redirection to an authentication provider, which `BakeryAuth` is designed to handle.
Review release notes for each update. Pin to exact versions for production use and thoroughly test upgrades.
Be aware of the upstream dependency's status. Monitor both macaroonbakery and pymacaroons for updates or potential issues.
It is strongly recommended to use `macaroonbakery` with Python 3.5+ to ensure compatibility and benefit from ongoing support.
Install the library using pip: `pip install macaroonbakery`
Ensure the library is installed (`pip install macaroonbakery`) and the import statement is correct: `from macaroonbakery import httpbakery`
Verify that the macaroon (or the API token leveraging macaroons) was correctly generated, has not expired, and is being used within its intended scope. Regenerate the macaroon if there are doubts about its integrity or validity.
Ensure `jar = requests.cookies.RequestsCookieJar()` is initialized once and consistently passed to `httpbakery.BakeryAuth(cookies=jar)` for all relevant `requests` calls to maintain the session and handle macaroons.