Issue with Google Drive API: Folder star status not updating in Drive interface

I’m having trouble with the Google Drive API. I’m trying to change a folder’s star status, but it’s not showing up in the actual Google Drive interface.

Here’s what I’m doing:

from cloud_service import CloudService
from auth_helper import get_credentials

creds = get_credentials('drive_api_config.json')
cloud = CloudService('drive', 'v3', creds)

# Create folder
folder_info = {
    'name': 'Test Folder',
    'type': 'folder',
    'parent': 'ROOT_FOLDER_ID'
}
new_folder = cloud.create_item(folder_info)

# Update folder
update_info = {
    'name': 'Updated Test Folder',
    'is_starred': True
}
cloud.update_item(new_folder['id'], update_info)

# Check updated info
result = cloud.get_item_info(new_folder['id'])
print(result)

The code runs without errors, and when I check the folder info, it shows as starred. But when I look in Google Drive, the star isn’t there. The name change works fine, just not the star.

I’ve waited over 15 minutes, but still no change. Any ideas on what might be going wrong or how to fix this?

hey man, i had this problem too. try using the ‘modifiedTime’ field when updating. like this:

update_info = {
‘name’: ‘Updated Test Folder’,
‘starred’: True,
‘modifiedTime’: datetime.utcnow().isoformat() + ‘Z’
}

This forces drive to update the file metadata. worked for me. good luck!

I’ve encountered a similar issue when working with the Google Drive API. In my experience, the star status sometimes doesn’t sync immediately with the Drive interface, even though the API reports it as updated.

One workaround I found effective was to force a refresh of the folder’s metadata. After setting the star, try modifying another property of the folder (like the description) immediately after. This seemed to trigger a faster sync with the Drive interface.

Also, make sure you’re using the correct scope in your credentials. The https://www.googleapis.com/auth/drive scope is needed for full access, including starring items.

If these don’t work, you might want to check if there are any caching issues on your end or if there’s a delay in Google’s systems. In rare cases, I’ve had to wait up to an hour for changes to propagate fully.

Lastly, double-check that you’re looking at the correct folder in the Drive interface. Sometimes, especially with programmatically created folders, it’s easy to mix them up if they have similar names.

I’ve dealt with this quirk in the Google Drive API before. The issue likely stems from the API’s caching mechanism, which can cause a delay in reflecting changes in the user interface.

One approach that’s worked for me is to use the ‘files.update’ method with the ‘fields’ parameter set to include ‘starred’. This explicitly tells the API to update and return the starred status:

updated_file = service.files().update(
    fileId=file_id,
    body={'starred': True},
    fields='starred'
).execute()

If that doesn’t resolve it, you might need to implement a polling mechanism to check the status periodically until it syncs. Also, ensure you’re using the correct authentication scope as mentioned by others.

Remember, some changes in Google Drive can take time to propagate across their systems, so patience might be key here.