8000 docs(iam-samples): extract json_key_file from privateKeyData (#7393) · dinoperovic/python-docs-samples@6f2f3d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f2f3d7

Browse files
authored
docs(iam-samples): extract json_key_file from privateKeyData (GoogleCloudPlatform#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
1 parent 650baa8 commit 6f2f3d7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

iam/api-client/service_account_keys.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ def create_key(service_account_email):
5050
name='projects/-/serviceAccounts/' + service_account_email, body={}
5151
).execute()
5252

53-
print('Created key: ' + key['name'])
53+
# The privateKeyData field contains the base64-encoded service account key
54+
# in JSON format.
55+
# TODO(Developer): Save the below key {json_key_file} to a secure location.
56+
# You cannot download it again later.
57+
# import base64
58+
# json_key_file = base64.b64decode(key['privateKeyData']).decode('utf-8')
59+
60+
if not key['disabled']:
61+
print('Created json key')
5462
# [END iam_create_key]
5563

5664

0 commit comments

Comments
 (0)
0