Below error throws while trying to delete the folder from the google drive
Error details
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()
Initial I tried to delete the file from the Gdrive service.Files.Delete(fileId).Execute(); But this does not work and therefore i came to known we need to create a permission but it does not work
while trying with the API i can able to do the necessary things 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;
}
User contributions licensed under CC BY-SA 3.0