I am unable to give a user, programmatically, permission to edit a file that uses realtime API.
I can however go to the docs.google.com and share that file with that user and in that case we can collaborate normally.
The difference between when I give permission programmatically and through docs.google.com is that through the former one I see that permission is can view
and in the latter one the permission is can edit
.
When setting permission programmatically I have tried to set the role to all of the three possibilities writer
, owner
and reader
but in all cases the final permission is only can view
.
This is my JavaScript code for granting permission:
function insertPermission(fileId, value, type, role) {
var body = {
'value': value,
'type': type,
'role': role
};
var request = gapi.client.drive.permissions.insert({
'fileId': fileId,
'sendNotificationEmails':true,
'resource': body
});
request.execute(function(resp) {console.log(resp); });
}
var value = 'Email of the user that is to get access';
var type = 'user';
var role = 'writer';
var fileIdP = fileId;
insertPermission(fileIdP,value,type,role);