IAP Toolkit
A library of utils to ease programmatic authentication with Google IAP (and ideally other IAPs in future).
PyPi
https://pypi.org/project/iaptoolkit/
Installation
With Poetry:
poetry add iaptoolkit
With pip:
pip install iaptoolkit
Quick Start / Example Usage
import requests
from iaptoolkit import IAPToolkit
iaptk = IAPToolkit(google_iap_audience="EXAMPLE_ID_123456789ABCDEF")
allowed_domains = ["example.com", ]
# Example #1 - Combined Calls
def example1(url: str):
headers = dict()
result = iaptk.check_url_and_add_token_header(
url=url,
request_headers=headers,
iap_audience="some_iap_audience_string" # OAuth Client ID for the IAP-protected resource as 'audience'
valid_domains=allowed_domains
)
# result.token_added (bool) indicates if the token was added, depending on whether or not URL was valid
# headers dict now contains the appropriate Bearer Token header for Google IAP
# Make HTTP GET request with requests lib, with our headers containing bearer token to auth with IAP
response = requests.request("GET", url, headers=headers)
# Example #2 - Separate Calls - Functionally the same as Example 1 but more flexibility in URL validation
def example2(url: str):
is_url_safe: bool = iaptk.is_url_safe_for_token(url=url, valid_domains=valid_domains)
if not is_url_safe:
raise ExampleBadURLException("This URL isn't safe to send token headers to!")
headers = dict()
token_is_fresh: bool = iaptk.get_token_and_add_to_headers(
request_headers=headers,
iap_audience="some_iap_audience_string" # OAuth Client ID for the IAP-protected resource as 'audience'
)
# token_is_fresh indicates if token was newly retrieved (True), or if a cached token was reused (False)
# headers dict now contains the appropriate Bearer Token header for Google IAP
# Make HTTP GET request with requests lib, with our headers containing bearer token to auth with IAP
response = requests.request("GET", url, headers=headers)
# Example #3 - Service Account JWT (instead of OIDC Token)
def example3(url: str):
headers = dict()
result = iaptk.check_url_and_add_jwt_header(
url=url,
request_headers=headers,
service_account_email="service-account@PROJECT_ID.iam.gserviceaccount.com",
url_audience="https://some-iap-protected.resource/path",
valid_domains=allowed_domains
)
# result.token_added (bool) indicates if the token was added, depending on whether or not URL was valid
# headers dict now contains the appropriate Bearer JWT header for Google IAP
# Make HTTP GET request with requests lib, with our headers containing bearer token to auth with IAP
response = requests.request("GET", url, headers=headers)
# Example #4 - Separate Calls - Service Account JWT - Functionally the same as Example 3 but more flexibility in URL validation
def example4(url: str):
is_url_safe: bool = iaptk.is_url_safe_for_token(url=url, valid_domains=valid_domains)
if not is_url_safe:
raise ExampleBadURLException("This URL isn't safe to send token headers to!")
headers = dict()
token_is_fresh: bool = iaptk.get_jwt_and_add_to_headers(
request_headers=headers,
service_account_email="service-account@PROJECT_ID.iam.gserviceaccount.com",
url_audience="https://some-iap-protected.resource/path"
)
# token_is_fresh indicates if token was newly retrieved (True), or if a cached token was reused (False)
# headers dict now contains the appropriate Bearer Token header for Google IAP
# Make HTTP GET request with requests lib, with our headers containing bearer token to auth with IAP
response = requests.request("GET", url, headers=headers)
Disclaimer
This project is not affiliated with Google. No trademark infringement intended.
Metadata
Release files for iaptoolkit 0.5.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iaptoolkit-0.5.5.tar.gz | 12.6 kB | With provenance | Details for iaptoolkit-0.5.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iaptoolkit-0.5.5-py3-none-any.whl | Python 3 | none | any | Details for iaptoolkit-0.5.5-py3-none-any.whl |
Total release size: 28.5 kB
Release files / iaptoolkit-0.5.5.tar.gz
| Download URL | iaptoolkit-0.5.5.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be6914fac6e1528ec721edd3b56a24496767da14b3875170b4fa988ff5420d0e
|
|
BLAKE2b-256 checksum How to use checksums |
5947c4f511d0b4e42c6bf5a3b91fcc4af75b6e03c707327bad036f699642e308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / iaptoolkit-0.5.5-py3-none-any.whl
| Download URL | iaptoolkit-0.5.5-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
251ee3677011a42c6a18b8266aa9bdd82abca36044ffbe70969aeb03b2250074
|
|
BLAKE2b-256 checksum How to use checksums |
1c72a9aee0ec633a1afb17ee3b82a3a72e901601bf8583b08a6911eeb75fda95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for iaptoolkit 0.5.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for iaptoolkit-0.5.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.