this.backupName = backupName;
this.historyCount = history;
this.historyName = history > 0 ? backupName + " " + new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss").format(new Date()) : null;
final HttpTransport httpTransport = new NetHttpTransport();
final JsonFactory jsonFactory = new JacksonFactory();
final GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, googleDriveOptions.getClientID(), googleDriveOptions.getClientSecret(),
Arrays.asList(DriveScopes.DRIVE)).setAccessType("offline").setApprovalPrompt("auto").build();
this.clientTokenPath = Paths.get(googleDriveOptions.getClientTokenPath());
try {
final String clientTokenAsJson = Files.exists(this.clientTokenPath) ? FileUtils.readFileToString(this.clientTokenPath.toFile()) : null;
credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()).setJsonFactory(new GsonFactory())
.setClientSecrets(googleDriveOptions.getClientID(), googleDriveOptions.getClientSecret()).build();
if (StringUtils.isEmpty(clientTokenAsJson)) {
final String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URL).build();
System.out.println("Please open the following URL in your browser, copy the authorization code and enter below.");
System.out.println("\n" + url + "\n");
final String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
clientToken = flow.newTokenRequest(code).setRedirectUri(REDIRECT_URL).execute();
storeClientToken(jsonFactory);
LOGGER.log(Level.INFO, "client token stored in '" + this.clientTokenPath + "'");
} else {
clientToken = jsonFactory.createJsonParser(clientTokenAsJson).parse(GoogleTokenResponse.class);
}
credential.setFromTokenResponse(clientToken);
} catch (final IOException e) {