}
/** Authorizes the installed application to access user's protected data. */
private Credential authorize() throws Exception {
// set up file credential store
final FileCredentialStore credentialStore = new FileCredentialStore(
new File(System.getProperty("user.home"), ".credentials/calendar.json"), jsonFactory);
// set up authorization code flow
final GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, Collections.singleton(CalendarScopes.CALENDAR))
.setCredentialStore(credentialStore)