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

Fix for drive operations requiring clientId #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions pyicloud/services/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def send_file(self, folder_id, file_object):

def create_folders(self, parent, name):
"""Creates a new iCloud Drive folder"""
# when creating a folder on icloud.com, the clientID is set to the following:
temp_client_id = f"FOLDER::UNKNOWN_ZONE::TempId-{uuid.uuid4()}"
request = self.session.post(
self._service_root + "/createFolders",
params=self.params,
Expand All @@ -166,7 +168,7 @@ def create_folders(self, parent, name):
"destinationDrivewsId": parent,
"folders": [
{
"clientId": self.params["clientId"],
"clientId": temp_client_id,
"name": name,
}
],
Expand Down Expand Up @@ -198,6 +200,8 @@ def rename_items(self, node_id, etag, name):

def move_items_to_trash(self, node_id, etag):
"""Moves an iCloud Drive node to the trash bin"""
# when moving a node to the trash on icloud.com, the clientID is set to the node_id:
temp_client_id = node_id
request = self.session.post(
self._service_root + "/moveItemsToTrash",
params=self.params,
Expand All @@ -207,7 +211,7 @@ def move_items_to_trash(self, node_id, etag):
{
"drivewsid": node_id,
"etag": etag,
"clientId": self.params["clientId"],
"clientId": temp_client_id,
}
],
}
Expand Down