X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/9b1705c5647864ef482078e1e169d6dfeade98b6..56129a5fcbcbe51a7ac7d6b009d4551ed9f71109:/auth.go diff --git a/auth.go b/auth.go index 1908b89..736624e 100644 --- a/auth.go +++ b/auth.go @@ -63,7 +63,6 @@ type chatgptAuth struct { path string issuer string http *http.Client - clock func() time.Time } // tokenFile is the content of the token file. @@ -115,7 +114,6 @@ func newChatGPTAuth(path, issuer string) *chatgptAuth { path: path, issuer: issuer, http: &http.Client{}, - clock: time.Now, } } @@ -308,7 +306,7 @@ func (a *chatgptAuth) Authorize(ctx context.Context, header http.Header) error { } expiry, found := tokenExpiry(tokens.AccessToken) - if !found || !a.clock().Before(expiry.Add(-refreshMargin)) { + if !found || !time.Now().Before(expiry.Add(-refreshMargin)) { tokens, err = a.refresh(ctx, tokens) if err != nil { return err