Consume updated kv module

Exposing store_path to the tokens module to support the newly updated kv
module, which requires an explicit storePath parameter.
This commit is contained in:
William Carroll 2020-02-23 20:00:04 +00:00
parent b5d4f547d2
commit a1a4689ad3
3 changed files with 7 additions and 4 deletions

View file

@ -7,6 +7,7 @@
source_up source_up
export monzo_client_id="$(pass show finance/monzo/client-id)" export monzo_client_id="$(pass show finance/monzo/client-id)"
export monzo_client_secret="$(pass show finance/monzo/client-secret)" 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_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_account_id="$(pass show finance/youneedabudget.com/personal-access-token)"
export ynab_budget_id="$(pass show finance/youneedabudget.com/budget-id)" export ynab_budget_id="$(pass show finance/youneedabudget.com/budget-id)"

View file

@ -76,6 +76,7 @@ var chans = &channels{
var ( var (
monzoClientId = os.Getenv("monzo_client_id") monzoClientId = os.Getenv("monzo_client_id")
monzoClientSecret = os.Getenv("monzo_client_secret") 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) { func persistTokens(access string, refresh string) {
log.Println("Persisting tokens...") log.Println("Persisting tokens...")
kv.Set("monzoAccessToken", access) kv.Set(storePath, "monzoAccessToken", access)
kv.Set("monzoRefreshToken", refresh) kv.Set(storePath, "monzoRefreshToken", refresh)
log.Println("Successfully persisted tokens.") log.Println("Successfully persisted tokens.")
} }
@ -221,8 +222,8 @@ func main() {
}() }()
// Retrieve cached tokens from store. // Retrieve cached tokens from store.
accessToken := fmt.Sprintf("%v", kv.Get("monzoAccessToken")) accessToken := fmt.Sprintf("%v", kv.Get(storePath, "monzoAccessToken"))
refreshToken := fmt.Sprintf("%v", kv.Get("monzoRefreshToken")) refreshToken := fmt.Sprintf("%v", kv.Get(storePath, "monzoRefreshToken"))
log.Println("Attempting to retrieve cached credentials...") log.Println("Attempting to retrieve cached credentials...")
logTokens(accessToken, refreshToken) logTokens(accessToken, refreshToken)

View file

@ -81,6 +81,7 @@ in {
script = "/home/wpcarro/.nix-profile/bin/token-server"; script = "/home/wpcarro/.nix-profile/bin/token-server";
environment = { environment = {
store_path = "/var/cache/monzo_ynab";
monzo_client_id = readSecret "monzo-client-id"; monzo_client_id = readSecret "monzo-client-id";
monzo_client_secret = readSecret "monzo-client-secret"; monzo_client_secret = readSecret "monzo-client-secret";
ynab_personal_access_token = readSecret "ynab-personal-access-token"; ynab_personal_access_token = readSecret "ynab-personal-access-token";