Programmatically Share Editing Rights of Google Site using a Google Form (Semi-Public Wiki) - google-apps-script

I have an existing (classic) Google Site that I would like to be a semi-public wiki. Google seems to have explicitly disallowed public wikis in the new version of sites, so I'm trying to find a work-around of sorts.
Here's my ideal flow:
1. Guest visits my Google site "Foo Wiki" and clicks a link to become a contributor.
2. Link goes to my Google Form "Registration Form" that just asks for
a name and email address.
3. Form submission creates a new line in a google sheet "Registration List".
4. "Registration List" has a script that emails the user's given email address
giving them editing rights to "Foo Wiki"
Is this possible?
I have the easy parts (1-3) done, but not sure how to go about step 4.

I think you can easily get this done using the addEditor() api.
Kindly check this out https://developers.google.com/apps-script/reference/sites/site#addEditor(User)

Actually it was even easier than I thought! I sent a second edit invite by email to another email address I had and copied the invite acceptance link to be on my site.

Related

Is there a way to get the current label name/id of a selected Mail?

I was wondering if its possible to get the current label name/id of the label the user selected in gmail.
I can get all labels a mail thread has, but I want to figure out which label the user currently looks at.
Maybe there is also a posiibility to parse the url of gmail in google app script? I know there is server side and client side but I dont have any other idea...
Thanks for your help
Anne
Google Workspace doesn't have a feature to retrieve what email or label a user is currently looking at in their Gmail. This request can be promoted for future development through the Google Workspace Feature Ideas Community.
What you can do with the Gmail API is list the messages in the user's mailbox and list all labels in the user's mailbox.

How to avoid Restricted Scopes OAuth verification process for private scripts used only by me?

I have received email from Google with subject: [Action Required] Submit your app(s) for Restricted Scopes OAuth verification,
same as many of you.
I'm using GAS only for developing applications for my personal use - not for public. Applications such as sending summary emails to my clients, when they buy a product from my web pages.
Do I have to go through the whole process of verification?
Do I have to create public Terms of Service?
Is there any way how I can explain to google, that my applications are not used by anybody else then by
me?
How to get to know for sure that my app won't stop?
I have read through FAQ (https://support.google.com/cloud/answer/9110914) and many other documents by google about this topic..
I have checked similar questions found on web, but with no luck of answers.. It looks it's pretty new experience for all of us..
Thank you for any advices.
I have personal account, so I can't use "internal apps" selection, this works only for paid G-suite customers which I'm not.
EDIT:
As Yoel Vinitsky stated, app doesn't need verification if it has only one user.
Here at bottom: https://support.google.com/cloud/answer/7454865 is table which shows that there is quota 100 new users in total, once the app presents the unverified app screen.
It seems like that I don't have to worry about verification of my apps at all, because I'm the only one user or maybe I use this app from 2 or 3 more users emails so it should be ok, my question is, is it going to be ok without verification, or not?
EDIT 2:
Google sent clarification email:
NO ACTION is required if:
Only owners use the project: If the project is only used by owners of the project, no action is required.
To determine whether you are an owner (versus an editor or viewer), follow these steps:
Click the project link above to navigate to its OAuth Consent Screen
configuration page.
Click the Navigation Menu button in the
upper-left corner, select IAM & admin, and click IAM. This will show you all project contributors and their roles.
The project doesn’t have users outside of your G Suite domain:If the project owner is using a G Suite account and the project is only used by Google Accounts in the project owner’s domain, no action is required (learn more here).
But the question is how to avoid verification with personal accounts for my own scripts used only by me?
As mentioned in the support FAQ You linked to:
When can I skip publishing my app for a review?
You do not need to request for verification if your app is
going to be used in any of the following scenarios:
1) The app is not shared with anyone else.
2) The app is used to send emails through WordPress, or
3) similar single account SMTP plug-ins.
The only drawbacks should be the warning that your app is unverified and maybe quota limits.

How can I set such "track" link in gmail?

I saw the following "Track order" link in Flipkart's order confirmation mail (gmail):
How do I acheive this? I don't know what it is called, so don't know what to search for. I apologize if this question is already asked.
This is done using an Email Schema via schema.org.
Google uses this service to allow rich markup of emails (https://developers.google.com/gmail/markup/overview)
You will need to register with Google and comply with their guidelines in order to use a schema in an email to provide a deep-link to your website.
The guidelines are located here: Registering with Google
In Summary:
Emails must be authenticated with SPF or DKIM
Emails must come from a static address and must follow Google's Bulk Sender Guidelines
The link must be to a specific page on your website and the label should clearly reflect the intent of the action
There's a few more, but these are the main requirements. Once you comply, you need to email schema.whitelisting+sample#gmail.com to allow Google to ensure you comply with the requirements and white list your domain for deep-linking.

geteditors not returning emails the ui decides is a group

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

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}