Google カレンダー API を使用してバックグラウンド操作を実行するユーティリティと、ユーザー インターフェイスなしでサーバー側の認証フローを実装しました。ここで、オフライン アクセスの認証フローを使用せずにプライベート カレンダーからイベントを読み取るか、カレンダーを公開したいと考えています。
認証に次のコードを使用しています。
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(SchedulerCalendar.HTTP_TRANSPORT)
.setJsonFactory(SchedulerCalendar.JSON_FACTORY)
.setServiceAccountId(SchedulerCalendar.SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(SchedulerCalendar.SCOPES)
.setServiceAccountPrivateKeyFromP12File(new File("key.p12")).build();
読み取りカレンダー イベントの場合は次のとおりです。
List eventslist = calendar.events().list(calendarid);
カレンダーが見つからない場合の応答は 404 です。
なにか提案を?