您可以使用permissions.insert
方法。
插入文件或團隊雲端硬盤的權限。
要查看參數和更多詳細信息,請嘗試訪問documentation。
在這裏,我爲您提供了上述文檔中介紹的.NET的示例代碼。
using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;
using System.Net;
// ...
public class MyClass {
// ...
/// <summary>
/// Insert a new permission.
/// </summary>
/// <param name="service">Drive API service instance.</param>
/// <param name="fileId">ID of the file to insert permission for.</param>
/// <param name="value">
/// User or group e-mail address, domain name or null for "default" type.
/// </param>
/// <param name="type">The value "user", "group", "domain" or "default".</param>
/// <param name="role">The value "owner", "writer" or "reader".</param>
/// <returns>The inserted permission, null is returned if an API error occurred</returns>
public static Permission InsertPermission(DriveService service, String fileId, String value,
String type, String role) {
Permission newPermission = new Permission();
newPermission.Value = value;
newPermission.Type = type;
newPermission.Role = role;
try {
return service.Permissions.Insert(newPermission, fileId).Execute();
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
}
return null;
}
// ...
}
您也可以訪問此SO post作進一步討論。