Retrieve Email address of file owner permission?(apps domain) - google-drive-api

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

Related

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

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,

Do I have to share Google Drive folder for service account access?

I have created a service account for use with the Google Drive API as outlined here:
https://developers.google.com/drive/delegation
After all the reading I've done, my impression is that this service account should act on behalf of the actual account which is part of the Google Apps for Business domain being used.
With that, I would expect that no special permissions would be needed to be dealt with when dealing with Google Drive folders. However, after authenticating and trying to list the contents of a folder, nothing is shown.
If I add the service account email address specifically to the "share" list for the folder, everything seems to work as intended. I can list the files in the folder using the API.
My question is, is this the way it's supposed to be or am I missing something that would allow the service account to access folders on behalf of the actual account without having to specifically add the service account email address to the share list?
Thank you for your time.
You need to impersonate the user with his/her email. Go through the steps explained on https://developers.google.com/drive/delegation and use the snippets below for further coding reference.

Is there any way to download folder and files for specific user using box api?

I have a user which has co-admin privileages. i HAVE ACCESS AND AUTH TOKEN CORRESPONDING TO CO-ADMIN. In my code I first fetch all the users present under given enterprise account and then for some specific users i want to download all the folders and files. Is there any way to do so?. I know that box api does have GetFolder(). but this api does not take any arguments such as username . It requires a folder id and It will always return all the folders and files under that id.
It sounds like you want to use the On-Behalf-Of header. Once you've authenticated an admin account, you can use this header to make any API call on behalf any of the users in the admin's enterprise.

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

about service accounts and unregistered users

I have a web app in php mysql, I want to use one google drive account for my app.
Can I use my app's accounts instead of google users for privilages.
I read in SDK I can use service account to login without promting user, but I don't know how to share or give permissions files for custom users.
In api reference I found this:
"The user is not necessarily yet a Google user (e.g. if a file or folder is shared with an email address that does not yet have an associated Google account). Example: 1111459233037698895607".
How a custom user in my app should get a token for own privilages.
I am not exactly sure what you want to achieve here, but if you want to use your own permission system, you can't. You can, however, apply read/write/owner permissions to files to mirror your own permissions.
If I have totally got the wrong idea, please explain.