I'm trying to share a folder from a Ruby script using the following code:
def insert_file_permission(file_id, email)
drive = $client.discovered_api('drive', 'v2')
new_permission = drive.permissions.insert.request_schema.new({
'value' => email,
'type' => 'user',
'role' => 'reader'
})
result = $client.execute(
:api_method => drive.permissions.insert,
:body_object => new_permission,
:parameters => { 'fileId' => file_id, 'emailMessage' => 'This a shared folder', 'sendNotificationEmails' => true, 'withLink' => false})
log_results(email +': ' + file_id +' - file permission',result, true)
end
The share details when I look at the folder from the Owner's login show the folder as being shared by those users. But when I log in as the user account specified by the parameter "email", the folder is not visible in the their Drive.
I added the email options to see if this was related to a bug/feature that required users to click a link in an email to activate the share, but that seems to make it worse. They then get a message that they need to request access, which is odd since they are already listed as Shares.
Patience is a virtue. The answer is to give Google Apps for Business time to "catch up" when creating and deleting user accounts, especially when testing permissions on Google Drive.