title: Google Calendar API with Java - Service Account
body: <p>Referenced <a href="https://stackoverflow.com/questions/30818380/google-calendar-api-with-php-service-account">Google Calendar API with PHP – Service Account</a> and tried the following steps:</p>
  
  <ul>
  <li>Created a project in Google API console and enabled Google Calendar API on this project </li>
  <li>Created a service account under the project, downloaded the JWT format key</li>
  <li>Tried to share my personal calendar with the service account email, not sure whether it's UI bug or not allowed, there's no error, after refreshing the page, the service account email is gone. I had to use my company's Google account calendar and the service account can be added. </li>
  <li>Wrote Java code to use the JWT key from step 2, to get the Calendar list.</li>
  </ul>
  
  <hr>
  
  <pre><code>HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  // Build service account credential.
  
  GoogleCredential credential = GoogleCredential          .fromStream(this.getClass().getClassLoader().getResourceAsStream("makoto-c14c149ef994.json")).createScoped(Collections.singleton(CalendarScopes.CALENDAR));
  
  Calendar calendar = new Calendar.Builder(httpTransport, jsonFactory, credential).setApplicationName("makoto").build();
  
  return calendar.calendarList().list();
  </code></pre>
  
  <p><strong>The problems/questions are:</strong></p>
  
  <ol>
  <li>nothing listed from </li>
  </ol>
  
  <blockquote>
    <p>calendar.calendarList().list()</p>
  </blockquote>
  
  <p>which returned [], no error as well. did I miss anything?</p>
  
  <ol start="2">
  <li>why can't I share my personal calendar with the service account. Is this only available to enterprise google account?</li>
  </ol>