Доступ к личному календарю с помощью учетной записи службы Google?JAVA

Программисты JAVA общаются здесь
Anonymous
Доступ к личному календарю с помощью учетной записи службы Google?

Сообщение Anonymous »

Мне внушили, что я могу получить доступ к своему личному календарю из сервисной учетной записи, созданной под моей учетной записью Google. Я поделился своим календарем с адресом электронной почты сервисного аккаунта (с разрешения: просмотреть все сведения о мероприятии). Затем я создал следующий код:

Код: Выделить всё

    public static final List< String > SCOPES = new ArrayList();
static {
SCOPES.add( CalendarScopes.CALENDAR );
SCOPES.add( DriveScopes.DRIVE_READONLY );
SCOPES.add( SheetsScopes.SPREADSHEETS );
};

public GoogleCalendarUtilities( ) throws Exception {

final String JSON_TOKEN = """
{
REDACTED
}
""";

GoogleServiceAccountAuthenticationUtilities googleServiceAccountAuthenticationUtilities = new GoogleServiceAccountAuthenticationUtilities();
HttpRequestInitializer httpRequestInitializer = googleServiceAccountAuthenticationUtilities.getRequestInitializer( JSON_TOKEN ,
Constants.SCOPES );

NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();

calendarService = new Calendar.Builder( HTTP_TRANSPORT , JSON_FACTORY , httpRequestInitializer )
.setApplicationName( UUID.randomUUID().toString() )
.build();
}

/**
* Returns a list of CalendarListEntries.  You can get the calendar's "summary" and "id" from this object.
* Summary is the name you see on the calendar's web page.  Id is the key for accessing the calendar.
* @return
* @throws IOException
*/
public List< CalendarListEntry > getCalendarListEntries() throws IOException {
CalendarList calendarList = calendarService.calendarList().list().setPageToken( null ).execute();
return calendarList.getItems();
}
Но при этом календари не возвращаются, а это означает, что учетная запись службы не видит календарь моей личной учетной записи. Нужно ли мне где-то указывать, что меня интересуют только мои личные календари?
Я знаю, что OAuth 2 является лучшим решением, но меня интересует сервис-сервис, если это вообще возможно.

Подробнее здесь: https://stackoverflow.com/questions/798 ... ce-account

Вернуться в «JAVA»