From 7fe986c42961231d94fe7d33c9a3ba287f369323 Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Sun, 11 Aug 2024 20:53:54 -0500 Subject: [PATCH] allow SimpleFIN credentials via ENV --- README.md | 6 ++++++ track-investments.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 51fa1b7..0da0971 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,9 @@ INVESTMENT_PAYEE_NAME="Investment" INVESTMENT_CATEGORY_GROUP_NAME="Income" # optional, name of the category for added investment tracking transactions INVESTMENT_CATEGORY_NAME="Investment" + +# optional, for logging into SimpleFIN +SIMPLEFIN_CREDENTIALS="" ``` ## Installation @@ -215,6 +218,9 @@ You can optionally change the category group used for the transactions by settin You can optionally change the category used for the transactions by setting `INVESTMENT_CATEGORY_NAME` in the `.env` file. +You can optionally store the SimpleFIN credentials generated from your setup +token by setting `SIMPLEFIN_CREDENTIALS` in the `.env` file. + To run: ```console diff --git a/track-investments.js b/track-investments.js index 74902ed..07b98fb 100644 --- a/track-investments.js +++ b/track-investments.js @@ -6,6 +6,10 @@ require("dotenv").config(); const getCredentials = async () => { + if (process.env.SIMPLEFIN_CREDENTIALS) { + return process.env.SIMPLEFIN_CREDENTIALS; + } + const token = readline.question('Enter your SimpleFIN setup token: '); const url = atob(token.trim()); @@ -19,6 +23,7 @@ const getCredentials = async () => { const data = `${username}:${pw}`; fs.writeFileSync('simplefin.credentials', data); + console.log('SimpleFIN credentials:', data); return data; };