Reputation: 33
I am writing an angular code to give permission to another account to access a particular file in google drive.
public async givepremission(fileid,email){
await gapi.client.setApiKey(this.credconst.APIkey.toString());
return await gapi.client.load("drive","v3")
.then(async () =>
{
return await gapi.client.drive.permissions.create({
"fileId": fileid,
"resource": {
"role": "reader",
"type": "user",
"emailAddress": email
}
}) },
(err) => {
this.toastr.error('Google API error');
throw(err);
});
}
But all i am getting is an error
domain: "global"
reason: "required"
message: "Permission value field required"
locationType: "other"
location: "permission.value"
I tried it in the https://developers.google.com/drive/api/v3/reference/permissions/create Try This API there it is working fine but in my project it throws the above error.
The account I am using to give permission is not a G-Suite user.
I have no idea why this error pops up?
How can I solve this issue?
-Thanks
Upvotes: 0
Views: 977
Reputation: 1
Or other option, but no save but your "share folder with all".
permission = file.InsertPermission({
'type': 'anyone',
'value': 'anyone',
'role': 'writer'})
In python
Upvotes: 0
Reputation: 416
if you have a look here https://developers.google.com/drive/api/v2/reference/permissions/insert under "Optional Properties" you have the value field here's the requestBody you should pass:
requestBody:{
emailAddress:'[email protected]',
role:'writer',
type:'user',
value: '[email protected]'
},
I had the same error but now it works for me.
Upvotes: 1