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.
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',