Skip to main content

Get an GCP Credentials instance

Project description

gae-impersonate-credentials

Get an GCP Credentials instance

App runs in GCP, return None for use Application Default Credentials(ADC). When runs in local, impersonate requested service account by ADC. (In local environment, ADC is developer's own google account that signed in with gcloud auth application-default login in normal usage.)

If use this function on Cloud Functions Python 3.9 Runtime, this function cannot detect actual run environment, because not supplied to GOOGLE_CLOUD_PROJECT or GCP_PROJECT environment variables. You need to supply these value in deploy Cloud Functions deployment parameter or set is_run_on_gcp parameter in this function.

Example usage

from gae_credentials import get_credentials
from google.cloud import ndb


credentials = get_credentials(
    service_account='example@appspot.gserviceaccount.com',
    scopes=[
      'https://www.googleapis.com/auth/datastore'
    ]
)

client = ndb.Client(credentials=credentials)

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

gae-impersonate-credentials-0.1.5.tar.gz (6.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page