From: Pavel Rochnyak Date: Thu, 25 Oct 2018 05:05:29 +0000 (+0700) Subject: Merge pull request #2970 from octo/ff/oauth X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=dc29f865ff6be12cce9fa9d77466e866268a836e;hp=d68b39f201071634984948ab3187ffb846e90584 Merge pull request #2970 from octo/ff/oauth src/utils_oauth.c: Renew OAuth tokens 30 seconds before they expire. --- 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);