I have an mp4 video file that sits in the "Videos" folder in Google Drive. I want to get a shareable link to this file using C# sdk v3. In my code I set permissions for the file (and the folder):
string fileId = "..real..file..id..here.."
Google.Apis.Drive.v3.Data.Permission permission = new Google.Apis.Drive.v3.Data.Permission();
permission.Type = "anyone";
permission.Role = "reader";
permission.AllowFileDiscovery = true;
PermissionsResource.CreateRequest request = _service.Permissions.Create(permission, fileId);
request.Fields = "id";
request.Execute();
_service variable is a DriveService object. I can see that permissions are set correctly for the file (and for the folder). Then I try to get the link with the following code:
FilesResource.ListRequest listRequest = _service.Files.List();
List<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute().Files.ToList();
Google.Apis.Drive.v3.Data.File myVideo = files.Single(f => f.Id == fileId);
string shareableLink = myVideo.WebContentLink;
File "myVideo" is retrieved correctly, however, the WebContentLink property is null. What am I missing here?
Update: AllowFileDiscovery = false; doesn't make any difference.
Update: After permissions are set you can construct the url manually with the file id: https://drive.google.com/uc?id=..file..id..goes..here