diff --git a/monzo-ynab/.envrc b/monzo-ynab/.envrc new file mode 100644 index 000000000..6a45e34bd --- /dev/null +++ b/monzo-ynab/.envrc @@ -0,0 +1,2 @@ +export client_id="$(pass show finance/monzo/client-id)" +export client_secret="$(pass show finance/monzo/client-secret)" diff --git a/monzo-ynab/main.go b/monzo-ynab/main.go new file mode 100644 index 000000000..f5c9e9cbb --- /dev/null +++ b/monzo-ynab/main.go @@ -0,0 +1,41 @@ +// Creating a job to import Monzo transactions into YNAB. +// +// This is going to run N times per 24 hours. + +package main + +import ( + "fmt" + "log" + "net/http" + "os" + "os/exec" +) + +var ( + clientId = os.Getenv("client_id") + clientSecret = os.Getenv("client_secret") +) + +const ( + state = "xyz123" + redirectUri = "http://localhost:8080/authorize" +) + +func handleRedirect(w http.ResponseWriter, r *http.Request) { + fmt.Println(r) + fmt.Fprintf(w, "Ackified") +} + +func authorizeClient() { + url := + fmt.Sprintf("https://auth.monzo.com/?client_id=%s&redirect_uri=%s&response_type=code&state=:state", + clientId, redirectUri, state) + exec.Command("google-chrome", url).Start() +} + +func main() { + authorizeClient() + http.HandleFunc("/authorize", handleRedirect) + go log.Fatal(http.ListenAndServe(":8080", nil)) +}