Make folder a shared Google api v3 application?

I can make a folder using this code

var request = gapi.client.request({ 'path': '/drive/v3/files/', 'method': 'POST', 'headers': { 'Content-Type': 'application/json' //'Authorization': 'Bearer ' + token }, 'body':{ "name" : "copy", "mimeType" : "application/vnd.google-apps.folder", } }); request.execute(function(resp) { console.log(resp); //document.getElementById("info").innerHTML = "Created folder: " + resp.title; }); 

but I can’t understand how much I can make this folder accessible to everyone, I saw in the documentation to put the type: someone, but I can’t figure out how to do this in code, thanks for your time

+2
source share
1 answer

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:

+3
source

Source: https://habr.com/ru/post/1245695/


All Articles