restpostgoogle-drive-apigoogle-apis-explorer

How to create permission to read/view files?


How do I pass the permissions hash or json? correctly and maybe access token?

https://www.googleapis.com/drive/v3/files/file_id/permissions

This is the body I want

{
  "role": "reader",
  "type": "user",
  "emailAddress": "cratagg@gmail.com"
}

But I don't know how to include it in postman. I've been trying many ways but none seems to work. I couldn't either with the https://developers.google.com/oauthplayground/ - I may not know how to formulate the request.

The only thing that worked was the https://developers.google.com/drive/api/v3/reference/permissions/create "Try this API" section


Solution

  • The Try this API feature shows the HTTP implementation if expanded

    enter image description here

    So, in your case, the request would be:

    POST https://www.googleapis.com/drive/v3/files/[FILEID]/permissions?key=[YOUR_API_KEY] HTTP/1.1
    
    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    Content-Type: application/json
    
    {
      "role": "reader",
      "type": "user",
      "emailAddress": "cratagg@gmail.com"
    }
    

    Whereby you need to specify the API key and the FILEID.