You create permission for a file or folder using this REST function:
POST https://www.googleapis.com/drive/v3/files/fileId/permissions
So you can do:
var fileId = File Id; var request = gapi.client.request({ 'path': '/drive/v3/files/' + fileId + '/permissions', 'method': 'POST', 'headers': { 'Content-Type': 'application/json' //'Authorization': 'Bearer ' + token }, 'body':{ 'role': 'reader', // owner, writer, commenter 'type': 'anyone' } });
If it succeeds, as a result, it will provide you with a permissions resource:
{ kind: "drive#permission", id: Unique identifier, type: string, emailAddress: string, domain: string, role: string, allowFileDiscovery: boolean, displayName: string, photoLink: string }
I give you links to the link, but I did not find any example there:
source share