]> git.cworth.org Git - turbot/commitdiff
Correct the code storing the picked base64 token
authorCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2020 01:48:08 +0000 (18:48 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2020 01:48:08 +0000 (18:48 -0700)
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.

turbot_lambda/turbot_lambda.py

index 80cc4d27a26bee30c7a8fbde7c90ecb80b88f541..46db3ce1fb6ebfe987e1500d7386de5de90e93ef 100644 (file)
@@ -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',