Sheets API v4에서는 수행 할 수없는 것처럼 보입니다.
그러나 호환 가능한 Google 드라이브 API v3을 사용하는 것처럼 보입니다.
참고 :이 솔루션에 대한 가장 좋은 점은 두 API에 대해 동일한 인증 및 자격 증명 수집 방법을 사용할 수 있다는 것입니다. 예를 들어, 일단 자격 정보를 얻으려는 코드가 있으면 두 API 모두에 대해 호환 가능하고 연속적으로 사용할 수 있습니다.
는 여기에 내가했던 일이야 :에
추가 된이 내 build.gradle
(내 시트 API 선언 아래 그림 참조)
compile('com.google.apis:google-api-services-sheets:v4-rev468-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-drive:v3-rev69-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
이미 계정 자격 증명을 얻기위한 EasyPermissions
방법을 사용했다. Great example here. 그런 다음
...
import com.google.api.services.drive.Drive;
...
protected Drive driveService = new Drive.Builder(transport, jsonFactory, credential)
.setApplicationName("My Application Name")
.build();
... 비동기 : 나는 (이상) 다른 사람을 위해 내 자신의 대답을 추가 할 것입니다 생각
private DateTime getSheetInformation() throws IOException {
String spreadsheetId = settings.getSpreadsheetId();
Drive.Files.Get fileRequest = driveService.files().get(spreadsheetId).setFields("id, modifiedTime");
File file = fileRequest.execute();
if (file != null) {
return file.getModifiedTime();
}
return null;
}
,하지만 나는 확실히 당신에게 신용을주고 있습니다. 때로는 "당신이 어차피!"라는 것을 아는 것이 중요합니다. 또한 어디로 갈까요 (Drive API files.get). 아주 많이 고마워! – LimaNightHawk