我正在尝试在Google云端硬盘中打印某个文件的权限。 在运行代码时,控制台不会打印出我们的结果,它只是说。
这部分有问题吗? :
System.out.println(permissions.getItems());
public class GoogleDriveListPermission {
public static void main(String[] args) throws IOException, GeneralSecurityException, URISyntaxException {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountPrivateKeyFromP12File(new java.io.File("eclipsejava-kjd7991s.p12"))
.setServiceAccountUser("admin@domain.com")
.setServiceAccountId("8969872333158-oj1ioad24f9t89da7sdfyhj2k@developer.gserviceaccount.com")
.setServiceAccountScopes(Arrays.asList(DriveScopes.DRIVE))
.build();
Drive service = new Drive.Builder(httpTransport, jsonFactory, credential)
.setApplicationName("Google Drive App1")
.build();
}
public static String fileId = "12u4QfIIOkM9rpoQvSrstMI8-3EJvZYp3jw1Gp3NSz";
public static String newOwner = "113598691748107335";
public static List<Permission> retrievePermissions(Drive service,
String fileId) {
try {
PermissionList permissions = service.permissions().list(fileId).execute();
System.out.println(permissions.getItems());
return permissions.getItems();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
return null;
}
}