1

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);
P̲̳x͓L̳
  • 3,615
  • 3
  • 29
  • 37
  • I don't see anything wrong with what you are doing there at a glance. Did you try duplicating the request you are trying to send on the "Try It" page here?https://developers.google.com/drive/v2/reference/permissions/insert You can compare what your http request looks like to the one it sends. – Cheryl Simon Mar 21 '14 at 15:40
  • @CherylSimon Thank you so much for the quick answer. That pointed me to the right direction to debbuging the code. The problem was I gave the wrong 'role' input to the insertPermission() function. That role variable had it's value set to 'read'. Again thank you. – user3446929 Mar 21 '14 at 16:12

0 Answers0