@@ -66,7 +66,14 @@ Service account private key files
6666+++++++++++++++++++++++++++++++++
6767
6868A service account private key file can be used to obtain credentials for a
69- service account. You can create a private key using the `Credentials page of the
69+ service account. But it is **not recommended ** to download a service account key. If you do need
70+ to use service accounts, you can do this instead:
71+
72+ * **local development **: Use :ref: `Impersonated Credentials<impersonation> ` with source credential as User Account
73+ * **google cloud production environment **: Use :ref: `Attached Service Account<MDS> `.
74+ * **non-google cloud production environment **: Use :ref: `Workload Identity Federation<wlif> `.
75+
76+ If none of the above alternatives work for you, wou can create a private key using the `Credentials page of the
7077Google Cloud Console `_. Once you have a private key you can either obtain
7178credentials one of three ways:
7279
@@ -113,6 +120,8 @@ credentials one of three ways:
113120.. _Credentials page of the Google Cloud Console :
114121 https://console.cloud.google.com/apis/credentials
115122
123+ .. _MDS :
124+
116125Compute Engine, Container Engine, and the App Engine flexible environment
117126+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118127
@@ -231,6 +240,8 @@ You can also use :class:`google_auth_oauthlib.flow.Flow` to perform the OAuth
231240.. _requests-oauthlib :
232241 https://requests-oauthlib.readthedocs.io/en/latest/
233242
243+ .. _wlif :
244+
234245External credentials (Workload identity federation)
235246+++++++++++++++++++++++++++++++++++++++++++++++++++
236247
@@ -976,12 +987,14 @@ configuration. It is not recommended to use a credential configuration that you
976987did not generate with the gcloud CLI unless you verify that the URL fields point
977988to a googleapis.com domain.
978989
990+ .. _impersonation :
979991
980992Impersonated credentials
981993++++++++++++++++++++++++
982994
983995Impersonated Credentials allows one set of credentials issued to a user or service account
984- to impersonate another. The source credentials must be granted
996+ to impersonate a service account. Impersonation is the preferred way of using service account for
997+ local development over downloading the service account key. The source credentials must be granted
985998the "Service Account Token Creator" IAM role. ::
986999
9871000 from google.auth import impersonated_credentials
@@ -1006,6 +1019,11 @@ In the example above `source_credentials` does not have direct access to list bu
10061019in the target project. Using `ImpersonatedCredentials ` will allow the source_credentials
10071020to assume the identity of a target_principal that does have access.
10081021
1022+ It is possible to provide a delegation chain through `delegates ` paramter while
1023+ initializing the impersonated credential. Refer `create short lived credentials delegated `_ for more details on delegation chain.
1024+
1025+ .. _create short lived credentials delegated : https://cloud.google.com/iam/docs/create-short-lived-credentials-delegated
1026+
10091027
10101028Downscoped credentials
10111029++++++++++++++++++++++
0 commit comments