How to get list of users requesting permissions for a file/folder using Google Drive - google-drive-api

Is there a way to get list of users requesting permission for a file/folder using Google Drive API.
I have seen API to grant permission to an email address using the API but couldn't find any endpoint to get list of users requesting access to a file/folder.
Ideally I want to fetch get all the users requesting permissions for my shared folders and approve/deny them.

This is not possible with current Drive API, but you could use Gmail API as a workaround:
list email by labels (add filter to those emails requesting access)
parse it
grant access to users you want with Drive API
Good luck,

Related

Get all users files in G Drive

We are developing an application, in that we need to get all the files of all users in the domain. We have enabled service account with domain-wide delegation already, but whenever we tried to access all user's drive, it is required to get each user access token separately after setting each user id using google credential object method (e.g. googleCredentialBuilder.setServiceAccountUser({email_id})). We are using Drive API client library for Java and admin SDK for getting all the users in the domain.
So, our concern is to get all users to drive files using a super admin access token. Is there any alternate way to get all users to drive files using domain/admin-level access token. Kindly help me in this regard.
To obtain all the Drive files in the domain, you have to use delegation as follows:
Use the Directory API users.list() API call to determine all users in the Google Apps domain.
For each user obtained in step 1, do:
2.1. Call files.list with the parameter q set to "me" in owners to get a list of all files the user owns.
To do all of this you don't necessarily need a superadmin account. You just need to set up credentials with domain-wide delegation enabled. You can read more about how to do it here.

Google Drive API Share document for offline writing/updating

I have created a web app which is making use of Google Drive API/ REST v2 (https://developers.google.com/drive/v2/web/about-sdk) to perform actions such as create/update/rename/delete of documents etc.
I am authorizing requests with OAuth 2.0 (client side - that means every access token is valid for ~1h and then silently I am getting a new token) and then perform previous actions using that token.
I have a new requirement for the authorized user to share his/her documents for writing/updating them (I found out that API has option for inserting permissions (https://developers.google.com/drive/v2/reference/permissions/insert : role: writer, type: anyone).
Is it possible for a non-authenticated user to be able to write/update documents (programmatically - via Google Drive API v2 or another API?) that have been created from the authenticated user that shared these? (something that is similar to google docs/ sharing when a user is sharing his document and offline users are able to edit it?
Thanks.
Is it possible for a non-authenticated user to be able to write/update documents (programmatically - via Google Drive API v2 or another API?) that have been created from the authenticated user that shared these? (something that is similar to google docs/ sharing when a user is sharing his document and offline users are able to edit it?
What you are describing here is something called a service account. Service accounts are like dummy users. You can share a file on your Google drive account with the service accounts email address and the service account will then have access to that file. Assuming that you gave them edit permissions it will be able to read and write to it without authenticating.
Note: service accounts do not work client sided you will need to use a server sided language to use service accounts.

How to avoid user consent in Google Drive API

I have integrated Google Drive API with Salesforce. But I would like to avoid "USER CONSENT" manually. Instead I am looking for providing access through REST API. Can anyone help on this.
All applications that access the data of a Google account must obtain the user's consent. It is possible via the Google Apps Marketplace for an admin to grant access for all the user's in their domain, but still some sort of consent is required.

Drive API - External Sharing

I know that the Google Drive SDK does not show the user email in the value field of the permission object due to privacy concerns. If we don't have that user email address, is there a way to know if a document is shared with anyone outside of the domain?
Also, wouldn't retrieving permissions using the document's owner authentication allow us to see that email address?
You cannot do that using Drive API. However, you can achieve this result using the old and deprecated Gdata DocumentList API

Retrieve Email address of file owner permission?(apps domain)

I have the owner permission of a certain file. I wan't to share this file around in the domain. For this in need to impersonate the owner. To impersonate a user I use a service account, but I still need a ServiceAccountUser. The serviceAccountUser is the email adress of the owner.
I can read the owner name from the permission but I don't know how to get his email adress.
I got suggested to use the profile API to gather this information, but I was wondering if there isn't a way to do this with the drive api.
How can I retrieve the Email adress of the file owner permission?
You cannot do that with Drive API, until Google hopefully changes it.
You will have to use the old Document List API and its AclFeed to retrieve the emails of your users