I’m having trouble with the Google Drive API when trying to mark a folder as starred. The API call seems to work fine and returns the correct values when I check, but the star doesn’t appear in the actual Google Drive web interface.
When I update other properties like the folder name, those changes show up immediately. But the starred property just won’t reflect in the UI even though the API says it worked.
Here’s how I’m creating the directory first:
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
from config import DRIVE_API_CREDENTIALS, ROOT_DIRECTORY_ID
SCOPES = ["https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_dict(
DRIVE_API_CREDENTIALS, SCOPES
)
drive_service = build("drive", "v3", credentials=creds, cache_discovery=False)
folder_metadata = {
"name": "My Test Directory",
"mimeType": "application/vnd.google-apps.folder",
"parents": [ROOT_DIRECTORY_ID],
}
new_folder = drive_service.files().create(body=folder_metadata, fields="id").execute()
Then I try to update both the name and starred status:
update_data = {"name": "Updated Directory Name", "starred": True}
modified_folder = (
drive_service.files()
.update(fileId=new_folder["id"], body=update_data, fields="name, starred")
.execute()
)
When I verify the changes:
verify_folder = (
drive_service.files().get(fileId=new_folder["id"], fields="name,starred").execute()
)
print(verify_folder)
This outputs: {'name': 'Updated Directory Name', 'starred': True}
But when I look in Google Drive, the folder name is changed but there’s no star icon visible. Is this a known issue or am I missing something in my implementation?