Performs authentication for Google Cloud Identity Aware Proxy from a service account
Project description
Google IAP authentication
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.
Install
pip install iap-auth
Usage
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>.apps.googleusercontent.com'
URL = 'https://your-iap-protected-website.com.br'
METHOD = 'GET'
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>.googleusercontent.com"
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>.apps.googleusercontent.com'
URL = 'https://your-iap-protected-website.com.br'
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iap-auth-0.2.1a1.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for iap_auth-0.2.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17f3e281b5c63be002530ce149d775b7144d8f69ab4052b086c62ab6f16fbfff |
|
MD5 | e0ca184f669f37bb3a6e93976e0d9876 |
|
BLAKE2b-256 | 63f6e442ba3e115b39f9da991783eb1603d06d7fe096a5603001da16abc7f913 |