obtain Google GCloud configuration credentials
Project description
gcloud config helper
This library allows you to use the current gcloud configuration credentials to authenticate with against the google APIs.
The library provides the class GCloudCredentials which wraps the gcloud config config-helper command.
To use:
import gcloud_config_helper credentials, project = gcloud_config_helper.default()
Next you can pass these credentials in when constructing an API client:
from google.cloud import compute_v1 c = compute_v1.InstancesClient(credentials=credentials) for zone, instances in c.aggregated_list(request={"project": project}): for instance in instances.instances: print(f'found {instance.name} in zone {zone}')
Note that Google documentation states that gcloud config config-helper should be regarded as an unstable interface.
if you want, you can use the gcloud_config_helper.on_path() to determine to use gcloud or the default credentials:
if google_config_helper.on_path(): credentials, project = gcloud_config_helper.default() else: logging.info("using application default credentials") credentials, project = google.auth.default()
obtain Google gcloud configuration credentials
Free software: Apache Software License 2.0
History
0.1.0 (2021-04-24)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gcloud_config_helper-0.3.1.tar.gz
.
File metadata
- Download URL: gcloud_config_helper-0.3.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a40d3612116a43c6db14f363cfe14860e7b1161c4c560ed29d9263e28ff2979e |
|
MD5 | 4148208f04527e4f57d298b6f7a9444d |
|
BLAKE2b-256 | 77fcc39b5e2410f59d5c989b54522e4e3cd3d89c07b82b8452a331a46c4feb8e |
File details
Details for the file gcloud_config_helper-0.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: gcloud_config_helper-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 967f14a626b34b595e62a00311b66c3f68eed62f71d97a99ebad9e46eadf436f |
|
MD5 | a195e0e6c888fdfdb67cf51608b7c217 |
|
BLAKE2b-256 | 67c06bee73d1ad1e7481f01b257d8f292ceebcb7783169c787b5d2afe040a8ef |