Manager removed from shared drive causes failure
As the shared drive list with permissions isn't scanned every time (as it takes a while), there can occasionally be a state where someone listed as a manager is no longer. If the tool then (if it happens to be first) tries to use this manager to scan the files in the shared drive will give the following error:
Encountered 403 Forbidden with reason "teamDriveMembershipRequired"
This will continue until the shared drive list refresh happens (or the person is re-added as a manager).
The code currently attempts to validate a manager by getting the manager's personal storage quota usage. While this validates that the manager hasn't been deleted (why this was put in), it doesn't validate that the manager still has permissions to the shared drive.
Hopefully, simple fix is to replace this check with one that would only succeed if the manager still had appropriate permissions to the shared drive. Perhaps getting the shared drive meta data (drives().get()
)? This should be added as a is_manager_of_shared_drive()
function of the GoogleDriveConnection
class so its implementation can be adjusted if needed later.