Google云端硬盘上的文件权限插入错误

时间:2019-05-10 09:07:02

标签: google-drive-api drive google-drive-realtime-api

尝试从Google驱动器中删除文件夹时引发以下错误

错误详细信息

Google.GoogleApiException
  HResult=0x80131500
  Message=Google.Apis.Requests.RequestError
Insufficient Permission: Request had insufficient authentication scopes. [403]
Errors [
    Message[Insufficient Permission: Request had insufficient authentication scopes.] Location[ - ] Reason[insufficientPermissions] Domain[global]
]

  Source=Google.Apis
  StackTrace:
   at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__31.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Google.Apis.Requests.ClientServiceRequest`1.Execute()
   at EJ2FileManagerService.Models.GoogleCloud.Rename(String path, String name, String newName, String fileId, Boolean replace, Object[] data) in C:\Users\Syncfusion\Desktop\ej2-file-manager-core-service\Models\GoogleCloud.cs:line 144
   at EJ2FileManagerServices.Controllers.FileManagerController.FileOperations(FEParams args) in C:\Users\Syncfusion\Desktop\ej2-file-manager-core-service\Controllers\FileManagerController.cs:line 71
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()

我最初尝试从Gdrive删除文件  service.Files.Delete(fileId).Execute(); 但这是行不通的,因此我知道我们需要创建一个权限,但行不通

尝试使用API​​时,我可以做必要的事情 https://developers.google.com/drive/api/v2/reference/files/delete

 public static Permission InsertPermission(DriveService service, String fileId)
        {
            Permission newPermission = new Permission();
            newPermission.Value = "test@gmail.com";
            newPermission.Type = "user";
            newPermission.Role = "owner";
            try
            {
                return service.Permissions.Insert(newPermission, fileId).Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
            }
            return null;
        }

0 个答案:

没有答案