0
所以基本上我的Java應用程序爲我們的每個Google域用戶創建一個或幾個Google日曆。在Google Calendar API中創建羣組日曆
爲了克服日曆創建限制(每幾個小時左右25個密碼),我實現了模擬每個所述用戶的服務帳戶。所述服務帳戶具有在管理控制檯中定義的API訪問。
我已經創建了所有成功的日曆,通過設置:
.setServiceAccountUser("[email protected]").
但現在我需要爲每個組創建日曆。如果我試圖模擬一個用戶組(.setServiceAccountUser( 「[email protected]」)),我得到這樣的錯誤:
400 Bad Request
{
"error" : "access_denied",
"error_description" : "Requested scopes not allowed:
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly"
}
相關代碼:
private static HttpTransport httpTransport;
private static final String SERVICE_ACCOUNT_EMAIL = "[email protected]";
private static final String SERVICE_ACCOUNT_PKCS12_FILE_PATH = "path\to.p12";
JacksonFactory jsonFactory = new JacksonFactory();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(CalendarScopes.all())
.setServiceAccountPrivateKeyFromP12File(new java.io.File(
SERVICE_ACCOUNT_PKCS12_FILE_PATH))
.setServiceAccountUser("[email protected]")
.build();
client = new com.google.api.services.calendar.Calendar.Builder(httpTransport,
JSON_FACTORY, credential).setApplicationName(
APPLICATION_NAME).build();
Calendar entry = new Calendar();
entry.setSummary("summary");
Calendar result = client.calendars().insert(entry).execute();
爲什麼我不能冒充組用戶名創建組日曆? 如何以其他方式創建幾百組日曆?