GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes)
.setCredentialStore(credentialStore).build();
// Build the local server and bind it to port 9000
LocalServerReceiver localReceiver = new LocalServerReceiver.Builder()
.setPort(8080).build();
// Authorize.
return new AuthorizationCodeInstalledApp(flow, localReceiver)
.authorize("user");