Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed APIError: [403] when copying permissions #1515

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gspread/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,19 @@ def copy(
if p.get("deleted"):
continue

# .list_permissions() returns a list of permissions,
# even the folder permissions if the file is in a shared folder.
# We only want the permissions that are directly applied to the
# spreadsheet file, i.e. 'writer', 'commenter' and 'reader'.
perm_details = {
p_details.get("permissionType"): p_details.get("inherited")
for p_details in p.get("permissionDetails")
}
if p.get("role") in ("organizer", "fileOrganizer") and (
perm_details.get("file") or perm_details.get("member")
):
continue

# In case of domain type the domain extract the domain
# In case of user/group extract the emailAddress
# Otherwise use None for type 'Anyone'
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ commands = pytest {posargs} tests/
extend-ignore = E203
extend-exclude = .tox,./env,./gspread/__init__.py
max-line-length = 255
max-complexity = 10
max-complexity = 11
show-source = True
statistics = True

Expand Down
Loading