diff options
Diffstat (limited to 'authconf.go')
-rw-r--r-- | authconf.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/authconf.go b/authconf.go index 2e9b81b..2a59392 100644 --- a/authconf.go +++ b/authconf.go @@ -22,16 +22,14 @@ func Auth(authFile string) UTRSimple { } func WriteAuth(authFile string) { - authToken, err := GetOAuth(clientID) + authToken, err := GetOAuth() if err != nil { panic(err) } uT := GetUserToken(authToken) - err = os.MkdirAll("/home/venomade/.local/share/lifesigns", 0755) - // TODO: unhardcode - + err = os.MkdirAll(dataDir, 0755) if err != nil { panic(err) } @@ -42,7 +40,7 @@ func WriteAuth(authFile string) { } defer file.Close() - confString := fmt.Sprintf("%s\n%s\n%s", uT.AccessToken, uT.ExpiresIn, uT.RefreshToken) + confString := fmt.Sprintf("%s\n%d\n%s", uT.AccessToken, uT.ExpiresIn, uT.RefreshToken) _, err = file.WriteString(confString) if err != nil { panic(err) @@ -57,10 +55,8 @@ func ReadAuth(authFile string) UTRSimple{ } defer file.Close() - // Create a slice to hold the lines of the file var lines []string - // Read all lines from the file into the slice scanner := bufio.NewScanner(file) for scanner.Scan() { lines = append(lines, scanner.Text()) @@ -68,8 +64,7 @@ func ReadAuth(authFile string) UTRSimple{ var utrs UTRSimple - // Process each line using the appropriate function - if len(lines) >= 2 { // Change to 3 + if len(lines) >= 3 { utrs.AccessToken = lines[0] exp, _ := strconv.Atoi(lines[1]) utrs.ExpiresIn = exp |