From 7df4a9f4dbe735029329a1052727b635ac3e65aa Mon Sep 17 00:00:00 2001 From: Greg Finley Date: Mon, 25 Mar 2024 11:04:25 -0700 Subject: [PATCH] Pull token within run --- process_file/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/process_file/main.py b/process_file/main.py index fae94b3..fc69b39 100644 --- a/process_file/main.py +++ b/process_file/main.py @@ -11,10 +11,6 @@ mysql_config_str = os.environ["MYSQL_CONFIG"] mysql_config_dict = json.loads(mysql_config_str) secret_client = secretmanager.SecretManagerServiceClient() -dropbox_access_token = secret_client.access_secret_version( - name="projects/greg-finley/secrets/DROPBOX_ACCESS_TOKEN/versions/latest" -).payload.data.decode("utf-8") -dbx = dropbox.Dropbox(dropbox_access_token) mysql_connection = mysql.connector.connect( @@ -27,6 +23,10 @@ def run(event, context): + dropbox_access_token = secret_client.access_secret_version( + name="projects/greg-finley/secrets/DROPBOX_ACCESS_TOKEN/versions/latest" + ).payload.data.decode("utf-8") + dbx = dropbox.Dropbox(dropbox_access_token) filename = base64.b64decode(event["data"]).decode("utf-8") print(f"Processing {filename}...") dropbox_file = dbx.files_download("/" + filename)