1
我需要我的web應用程序的服務器能夠在沒有任何用戶干預的情況下在Drive文件夾中創建電子表格。Google Drive公共API訪問
使用我在開發人員控制檯的API & auth部分創建的公共API訪問密鑰,可以實現這種可能性嗎?
事情是這樣的:
Credential credential = new GoogleCredential().setAccessToken(apiAccessKey);
client = new Drive.Builder(httpTransport, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME).build();
File body = new File();
body.setTitle(name);
body.setMimeType("application/vnd.google-apps.spreadsheet");
body.setParents(Arrays.asList(new ParentReference()
.setId(folder)));
File file = client.files().insert(body).execute();
return file.getId();
感謝。