diff options
-rw-r--r-- | monzo_ynab/.envrc | 1 | ||||
-rw-r--r-- | monzo_ynab/tokens.go | 9 | ||||
-rw-r--r-- | nixos/configuration.nix | 1 |
3 files changed, 7 insertions, 4 deletions
diff --git a/monzo_ynab/.envrc b/monzo_ynab/.envrc index 50fd9db4ac25..16fd7e76a39c 100644 --- a/monzo_ynab/.envrc +++ b/monzo_ynab/.envrc @@ -7,6 +7,7 @@ source_up export monzo_client_id="$(pass show finance/monzo/client-id)" export monzo_client_secret="$(pass show finance/monzo/client-secret)" +export store_path="$(pwd)" export ynab_personal_access_token="$(pass show finance/youneedabudget.com/personal-access-token)" export ynab_account_id="$(pass show finance/youneedabudget.com/personal-access-token)" export ynab_budget_id="$(pass show finance/youneedabudget.com/budget-id)" diff --git a/monzo_ynab/tokens.go b/monzo_ynab/tokens.go index 7afd86e4cf72..4be967ccb803 100644 --- a/monzo_ynab/tokens.go +++ b/monzo_ynab/tokens.go @@ -76,6 +76,7 @@ var chans = &channels{ var ( monzoClientId = os.Getenv("monzo_client_id") monzoClientSecret = os.Getenv("monzo_client_secret") + storePath = os.Getenv("store_path") ) //////////////////////////////////////////////////////////////////////////////// @@ -151,8 +152,8 @@ func refreshTokens(refreshToken string) (string, string) { func persistTokens(access string, refresh string) { log.Println("Persisting tokens...") - kv.Set("monzoAccessToken", access) - kv.Set("monzoRefreshToken", refresh) + kv.Set(storePath, "monzoAccessToken", access) + kv.Set(storePath, "monzoRefreshToken", refresh) log.Println("Successfully persisted tokens.") } @@ -221,8 +222,8 @@ func main() { }() // Retrieve cached tokens from store. - accessToken := fmt.Sprintf("%v", kv.Get("monzoAccessToken")) - refreshToken := fmt.Sprintf("%v", kv.Get("monzoRefreshToken")) + accessToken := fmt.Sprintf("%v", kv.Get(storePath, "monzoAccessToken")) + refreshToken := fmt.Sprintf("%v", kv.Get(storePath, "monzoRefreshToken")) log.Println("Attempting to retrieve cached credentials...") logTokens(accessToken, refreshToken) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index a60164cb75bf..f98fe980ec7e 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -81,6 +81,7 @@ in { script = "/home/wpcarro/.nix-profile/bin/token-server"; environment = { + store_path = "/var/cache/monzo_ynab"; monzo_client_id = readSecret "monzo-client-id"; monzo_client_secret = readSecret "monzo-client-secret"; ynab_personal_access_token = readSecret "ynab-personal-access-token"; |