I can't download Google Drive files by shared link on the folder - https://drive.google.com/drive/folders/1zGSodg9aI48q2ER79LbJ6C-8BY3Xq-QI?usp=sharing
I tried with
Drive service = new Drive.Builder(new NetHttpTransport(),
GsonFactory.getDefaultInstance(),
null)
.setApplicationName("ApplicationName")
.build();
and I use Files API https://developers.google.com/drive/api/v3/reference/files/get
File file = service.files().get(realFileId)
.setKey("AIzaSyCPmyt3Krb1QFca57f6v4gkHxFj5DEm8ik")
.execute();
and it works for https://drive.google.com/file/d/1THGBI8GUa5_jaHpmQhZ68SHashs5h4Ef/view?usp=sharing
but what to do for https://drive.google.com/drive/folders/1zGSodg9aI48q2ER79LbJ6C-8BY3Xq-QI?usp=sharing?
UPD: The users create folders and share links, and after that, I want to load them using the server application
The link you have is from the Google drive web application share copy link button
this sharable link is not a true share.
The only way to be able to access a file using the google drive api would be if the file is public, if the user owns the file, or if the user has permissions on the file.
A true share of the file will add a record in the permissions for that user with that file.
Without the user actually having a permission record on the file your not going to be able to download it with the google drive api
also note that doing a true share of a directory does not always give the user access to all files with in that directory, in my experience often you dont have access to all the files that were there before it was shared with you.
If you want to see all of the files shared with the current authenticated user you can use the q parameter for file.list
q=sharedWithMe%3Dtrue
This will list all of the files currently shared with that user.
If you want to see folders shared with the currently authenticated user you could just add folder
q=sharedWithMe=true and mimeType='application/vnd.google-apps.folder'
Again this will only work if the file was actually shared with you not if they used the share link created in the google drive web application.