Print refresh token logs only on Debug
This commit is contained in:
parent
90b921ec0f
commit
428b894a71
9
token.go
9
token.go
@ -64,7 +64,9 @@ func doRefresh(refreshToken string) *Token {
|
|||||||
url := "https://app.velux-active.com/oauth2/token"
|
url := "https://app.velux-active.com/oauth2/token"
|
||||||
req, err := http.NewRequest("POST", url, strings.NewReader(reqBody))
|
req, err := http.NewRequest("POST", url, strings.NewReader(reqBody))
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
log.Printf("token refresh: %+v", req)
|
if Debug {
|
||||||
|
log.Printf("token refresh: %+v", req)
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := myClient.Do(req)
|
resp, err := myClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -97,11 +99,12 @@ func refreshToken(tokenFilePath string) *Token {
|
|||||||
|
|
||||||
expireTime := tokenFile.Refreshed.Add(time.Second * time.Duration(tokenFile.Token.ExpireIn))
|
expireTime := tokenFile.Refreshed.Add(time.Second * time.Duration(tokenFile.Token.ExpireIn))
|
||||||
if expireTime.Before(time.Now()) {
|
if expireTime.Before(time.Now()) {
|
||||||
log.Println("refreshing token")
|
|
||||||
resultToken = doRefresh(tokenFile.Token.RefreshToken)
|
resultToken = doRefresh(tokenFile.Token.RefreshToken)
|
||||||
writeCacheToken(tokenFilePath, resultToken)
|
writeCacheToken(tokenFilePath, resultToken)
|
||||||
} else {
|
} else {
|
||||||
log.Println("skip refreshing token")
|
if Debug {
|
||||||
|
log.Println("skip refreshing token")
|
||||||
|
}
|
||||||
resultToken = tokenFile.Token
|
resultToken = tokenFile.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user