Problem with transfer permissions to new copied sheet
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 979
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When using `gspread.authorize(self.credentials).copy(file_id=file_id, title=title, copy_permissions=True, folder_id=folder_id)` on enterprise shared drives, the error occurs: `gspread.exceptions.APIError: APIError: [403]: FileOrganizer role is only allowed on folders.`
**To Reproduce**
Steps to reproduce the behavior:
1. Upload Google Sheets to a Shared Corporate Drive
2. Give access to Google spreadsheet users, with the FileOrganizer role in the shared drive
3. Make a copy of this Google spreadsheet with the parameter `copy_permissions=True`
**Expected behavior**
Set access roles in a new Google spreadsheet and continue running the script without error
**Code example***
```
import gspread
from oauth2client.service_account import ServiceAccountCredentials
token = 'service_credentials.json'
url = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(token, url)
client = gspread.authorize(self.credentials)
client.copy(file_id=file_id,
title=title,
copy_permissions=True,
folder_id=folder_id)
```
**Environment info:**
- Windows
- Python 3.10.6 64-bit
- gspread==6.1.2
**Additional context**
I was able to fix this issue manually by opening client.py on line 329 and adding the following code there:
```
if str(p["role"]).lower() == 'fileorganizer' or str(p["role"]).lower() == 'organizer':
p["role"] = 'writer'
```
The error no longer appears
Contributor guide
Assessment
This issue has not been assessed yet.