From: Carl Worth Date: Tue, 20 Oct 2020 01:48:08 +0000 (-0700) Subject: Correct the code storing the picked base64 token X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;ds=sidebyside;h=a435b7ed04ed7ca1939867beaecb3a71b3aa3348;p=turbot Correct the code storing the picked base64 token Using 'str()' here was incorrect. That did go from a bytes value to a string, but it did it by adding "b'" to the beginning and "'" to the end, breaking the parsing of the base64 value. Here, instead, we use the decode('us-ascii') method on the bytes value. --- diff --git a/turbot_lambda/turbot_lambda.py b/turbot_lambda/turbot_lambda.py index 80cc4d2..46db3ce 100644 --- a/turbot_lambda/turbot_lambda.py +++ b/turbot_lambda/turbot_lambda.py @@ -37,11 +37,12 @@ if gsheets_creds: else: gsheets_creds.refresh(Request()) gsheets_pickle = pickle.dumps(gsheets_creds) - gsheets_pickle_base64 = base64.b64encode(gsheets_pickle) + gsheets_pickle_base64_bytes = base64.b64encode(gsheets_pickle) + gsheets_pickle_base64 = gsheets_pickle_base64_bytes.decode('us-ascii') print("Storing refreshed GSheets credentials into SSM") ssm.put_parameter(Name='GSHEETS_PICKLE_BASE64', Type='SecureString', - Value=str(gsheets_pickle_base64), + Value=gsheets_pickle_base64, Overwrite=True) service = build('sheets', 'v4',