Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Performs authentication for Google Cloud Identity Aware Proxy from a service account

Project description

Google IAP authentication Upload Python Package


This module contains a helper class to make requests to an app running behind a Google Identity-Aware Proxy. The code was obtained from the Google Programmatic authentication document.


pip install iap-auth


With application default credentials

If running outside Google Cloud Platform you need to specify env var GOOGLE_APPLICATION_CREDENTIALS to point to your authorized service account.

from iap_auth import IapClient

CLIENT_ID = '<your-project-client-id>'
URL = ''
kwargs = {}

client = IapClient(CLIENT_ID)
resp = client.make_iap_request(URL, method=METHOD, **kwargs)

# resp is a requests.Response object.

Authenticating a user account

This way users do not need to have a service account or Google SDK installed. You'll need to create an OAuth 2.0 client ID and then use this lib as follows:

from iap_auth.user_client import UserAuth, UserIapClient

OAUTH_ID = "<desktop-app-oauth-id>"
OAUTH_SECRET = "z6..desktop-app-oauth-secret..Ys1"
KEY_PATH = "/where/to/store/your/user-credentials.json"
IAP_OAUTH_ID = '<your-project-iap-client-id>'

URL = ''

user_auth = UserAuth(OAUTH_ID, OAUTH_SECRET, KEY_PATH)
client = UserIapClient(user_auth, IAP_OAUTH_ID)
resp = client.make_iap_request(URL, method=METHOD)

# resp is a requests.Response object.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for iap-auth, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size iap_auth-0.2.2-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size iap-auth-0.2.2.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page