X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_oauth.c;h=d804b51a0ffa04f02b593689a27ef879940b6c66;hb=9ccd38b6341bd42732ecbaa214012d01064f622a;hp=35533befbe531a1c5edc710e7fe3800497814ff5;hpb=cb3704e79da2bdd96c58aca72560cc02379fb0b4;p=collectd.git diff --git a/src/utils_oauth.c b/src/utils_oauth.c index 35533bef..d804b51a 100644 --- a/src/utils_oauth.c +++ b/src/utils_oauth.c @@ -425,9 +425,10 @@ static int new_token(oauth_t *auth) /* {{{ */ static int renew_token(oauth_t *auth) /* {{{ */ { - /* TODO(octo): Make sure that we get a new token 60 seconds or so before the - * old one expires. */ - if (auth->valid_until > cdtime()) + /* Renew OAuth token 30 seconds *before* it expires. */ + cdtime_t const slack = TIME_T_TO_CDTIME_T(30); + + if (auth->valid_until > (cdtime() + slack)) return 0; return new_token(auth);