From 6f2f3d71ef2a300da64998a4b67c896c3bff2c53 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Tue, 22 Feb 2022 19:00:41 +0530 Subject: [PATCH] docs(iam-samples): extract json_key_file from privateKeyData (#7393) * docs(iam-samples): extract json_key_file from privateKeyData field in service account * fix(iam-samples): lint fix - included base64 import * docs(iam-samples): Updated the comment acc to review * lint fix * updated acc to review comment --- iam/api-client/service_account_keys.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/iam/api-client/service_account_keys.py b/iam/api-client/service_account_keys.py index d9017f669eb3..9d8c9c187428 100644 --- a/iam/api-client/service_account_keys.py +++ b/iam/api-client/service_account_keys.py @@ -50,7 +50,15 @@ def create_key(service_account_email): name='projects/-/serviceAccounts/' + service_account_email, body={} ).execute() - print('Created key: ' + key['name']) + # The privateKeyData field contains the base64-encoded service account key + # in JSON format. + # TODO(Developer): Save the below key {json_key_file} to a secure location. + # You cannot download it again later. + # import base64 + # json_key_file = base64.b64decode(key['privateKeyData']).decode('utf-8') + + if not key['disabled']: + print('Created json key') # [END iam_create_key]