Added auto option to refresh token when needed

Using the auto=true option the token will be auto-generated only when needed