You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: helper.go
    path of file: ./repos/evcc/util/oauth
    
    the code of the file until where you have to start completion: package oauth

import (
	"time"

	"github.com/evcc-io/evcc/util"
	"golang.org/x/oauth2"
)

// Refresh refreshes the token every 5m. If token refresh fails 5 times, it is aborted.
func Refresh(log *util.Logger, token *oauth2.Token, ts oauth2.TokenSource, optMaxTokenLifetime ...time.Duration) {
	var failed int

	// limit lifetime of initial token
	limitTokenLife(token, optMaxTokenLifetime...)

	for range time.Tick(5 * time.Minute) {
		// get token- either 
    
func Refresh(log *util.Logger, token *oauth2.Token, ts oauth2.TokenSource, optMaxTokenLifetime ...time.Duration) {
	var failed int

	// limit lifetime of initial token
	limitTokenLife(token, optMaxTokenLifetime...)

	for range time.Tick(5 * time.Minute) {
		// get token- either previous or new
		t, err := ts.Token()
		if err != nil {
			// error means refresh failed
			failed++
			if failed > 5 {
				log.ERROR.Printf("token refresh: %v, giving up", err)
				return
			}

			log.ERROR.Printf("token refresh: %v", err)
			continue
		}

		failed = 0

		// limit lifetime of new tokens
		if t.Expiry != token.Expiry {
			token = t
			limitTokenLife(token, optMaxTokenLifetime...)
		}
	}
}