Print refresh token logs only on Debug

This commit is contained in:
Florian Eitel 2019-08-11 22:51:21 +02:00
parent 90b921ec0f
commit 428b894a71
Signed by: flo
GPG Key ID: 9987EAFEF6F686BB

View File

@ -64,7 +64,9 @@ func doRefresh(refreshToken string) *Token {
url := "https://app.velux-active.com/oauth2/token"
req, err := http.NewRequest("POST", url, strings.NewReader(reqBody))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
if Debug {
log.Printf("token refresh: %+v", req)
}
resp, err := myClient.Do(req)
if err != nil {
@ -97,11 +99,12 @@ func refreshToken(tokenFilePath string) *Token {
expireTime := tokenFile.Refreshed.Add(time.Second * time.Duration(tokenFile.Token.ExpireIn))
if expireTime.Before(time.Now()) {
log.Println("refreshing token")
resultToken = doRefresh(tokenFile.Token.RefreshToken)
writeCacheToken(tokenFilePath, resultToken)
} else {
if Debug {
log.Println("skip refreshing token")
}
resultToken = tokenFile.Token
}