geteditors not returning emails the ui decides is a group - google-apps-script

So you create a document in drive, then share it. You share it to someone inside google's network, the email address gets an icon of a single dude. But if you share it with someone outside of googles network, you get an icon of multiple dudes. At least you do when you share it with security set to anyone with the link can get in. Im not sure if this works in the other modes.
but anyways, you now write an app script that wants to send an email to everyone the file is shared with. so you use DocsList to get the file, then call the getEditors method to get the list of people that the file is shared with. The problem is it looks like that method only returns the email addresses with the icon of the single dude. How do I get the other email addresses?
If that can't happen, how do I tell Drive that the external email address I'm adding is in fact a person and not a group?

I think that happened because you shared to someone that do not have a google account.
In order to see the document with an identified ID they must have a google account (that do not mean a google email adress) You can create an account associated to your email adress here
for the second part of the question you can refer to that previous question here

Related

How to give write permissions only to UI app to write data to a Spreadsheet

I have developed a web application using Google scripts UIApp class which will collect the data of work done by each associate and writes data to my spreadsheet.
Problem I'm facing is I have to share my spreadsheet to all the associates with write permission where it enables them to see others data. I want to hide this sheet from all but they should also be able write data using the web application I shared.
Please let me know for more details or any code snippets
Note: I have Not used Google Form because I need change the list values dynamically based on the selection and the type of user.
You can deploy the app you have built with UiApp to be executed as "you" and allow access to anyone. The spreadsheet won't need to be shared anymore but as it is anyone (even anonymous if you are not in a domain) will be able to use it...
You'll have to implement an access control yourself, again this will be different in a domain or in a "normal" gmail account (in a domain you can get the user email, in a gmail account you can't)
(since apparently I can't comment.. but to follow up on this question.)
Is there a best practice for running as something other than really-yourself?
Say a team is managing it, or your a contractor who won't stay with the company, and so you're account and access is likely to go away.
I assume it results in creating a shared account, or perhaps a groups or something? You start getting into all sorts of ACL issues. And a simple ``run as yourself'' doesn't seem like a good long term solution.

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.

Name field not being returned for a contact

When I go to pull the full name on a certain contact (getFullName()) my script doesn't return any thing. However, when I make a change to the name from within the Gmail Contacts interface, it then returns the name. If I undo the change, I don't get the name.
Any reasons to this? The contact is another account of mine that's tied to my G+ account.
This is a very interesting find. I was able to reproduce this with some of my contacts as well. It must have something to do with the where these contacts were imported from or how they were manually created.
However, I dug a bit deeper and I do not believe this is an Apps Script issue, but a Google Apps Contact API issue. I found this same issue directly interaction with the Google Contacts API documented here -
https://developers.google.com/google-apps/contacts/v3/
This might be the same issue tracked in their issue tracker as #3171.
Bit more of the technical details of what I tried to confirm this -
a. Go to the oAuth playground at - https://developers.google.com/oauthplayground
and authorize manually for the scope of https://www.google.com/m8/feeds.
Once you click authorize, the tool will make your login and then authorize the playground tool to read your contacts.
b. Now, click the "Exchange Authorization Tokens" button to grab the final token for further REST calls.
c. Set the Request URI to https://www.google.com/m8/feeds/contacts/default/full and hit "Send the Request". You should get the XML dump on the right. Copy and view it in your favorite XML editor and you should see the same behavior you are describing above where Fullname only returns after an edit. You can narrow this down to invididual contacts (and stare at smaller XML files) by passing in a contact ID in the URL format of https://www.google.com/m8/feeds/contacts/default/full/{contactId}

user email in About service

I need to get the user email when I get document permissions. I have seen this problem here
value attribute for Permissions Resource not populated in responses
but in about service does not appear my email. I need it because I have a service account and my application need know the user email. I want to avoid call to profile service.
Is this possible? from where I can get the user email?
Thanks.
As you rightly say, you will have to make a call to the profile service. In some ways it is better like this, because it separates the concerns of the Drive API and the Profile API, and can use specific scoping to let the user know exactly what they are authorizing your app to do.

How to automatically respond to an e-mail

I would like to automatically respond to an e-mail with some information. The idea is to provide a self-service way for students to get grades and passwords. I see sample scripts that work on e-mails, but I need to:
look for a keyword in the subject to understand what type of information to provide (i.e., grade, password, etc.)
look at the e-mail of the inbound e-mail to identify the student (optionally locate a password)
look up the information (possibly in a spreadsheet)
create an e-mail and send it to the student
I am more familiar with using scripts with e-mail and spreadsheets, but I would prefer to create this on a Google Sites page or embed it in a wiki.
Thanks in advance for the help,
JDF
I am not sure how much detail you were looking for, or if you where looking for example code, but here are some high level things to think about.
First, if you are going to embed the code into a webpage that you want be able to access all your other Google things easaly. eg if i stored all the student names passwords and student numbers in an spreadsheet or database you have to set up permission to do so. Your website does not count as you "persay" because if you had it shared out then someone could potentally steal all your google stuff.
Take a good look through the Google appi google apps script. You can search your email by thread (subeject) and then go through the emails like that. I think all the function that you want are there.