easycloudapi.gcp.gcp_oauth package
Submodules
easycloudapi.gcp.gcp_oauth.gcp_oauth module
GCP Authentication
How to access GCP projects using best auth
- Reference:
Google Documentation: https://cloud.google.com/iam/docs/overview
OpenID Connect: https://developers.google.com/identity/openid-connect/openid-connect
Different Ways/Methods To Access GCP Cloud Resources:
With User Consent
By Service Account Json Key
By Default Access if application running on GCP ComputeEngine, CloudFunction, CloudRun, AppEngine, Kubernetes
With impersonate Service Account
- class src.easycloudapi.gcp.gcp_oauth.gcp_oauth.GCP_Authentication(project_id: str)[source]
Bases:
objectA class for GCP Authentication …
- Parameters:
project_id (str) – Google Project ID
- oauth_withUserConsent_googleURI(client_secret_file_path,
scopes)
Oauth method using user consent
- oauth_withUserConsent_googleURI(client_secret_file_path: str, scopes: list = ['openid']) bool[source]
GCP resources authentication By User Consent …
User will give consent by clicking on the link provided and after approving the consent, user will get token which he/She will pass to the application manually
- Parameters:
client_secret_file_path (str) – local path of the client secret json file
scopes (list) – default value is, [“openid”] example, scopes=[‘openid’, ‘https://www.googleapis.com/auth/cloud-platform’]
- Returns:
credentials – return credential object
- Return type:
google.oauth2.credentials.Credentials
Notes
- To Create Client Access Secret and TokenID follow below steps:
Open GCP Project and open
- First, create “OAuth consent screen”
#. provide app name, scopes(”https://www.googleapis.com/auth/cloud-platform”, “openid”) and add test users and developer email id
- Second, go to “”APIs & Services” -> “Credentials” -> “Create OAuth client ID”
select Application Type as “Desktop app”
store the client ID and secret_file