How to share Google Site with entire domain using Apps Script SitesApp? - google-apps-script

Using SitesApp.AddEditor() you can add users to a specific Google Site.
But how can you add the entire domain?
The Google Sites API allows this, just cannot figure out if that method was implemented in Apps Script.
It would appear not, just want to confirm.
Thanks

Just create a group that contains all users in the domain, then add that group as an editor.

Google Apps Script Sites service does not (yet) have a method to set/change the visibility of sites. However, there are possible work-arounds for this:
By default, all users in a domain can find and edit newly created sites. You do not have to add individual users as editors in this case. Google Apps administrator for your domain may have changed the default visibility setting to private, though. In this case you/site owner will have to change this setting on per-site basis by adding users as viewers/editors to the site (read on below). Check with your Google Apps administrator about default visibility setting for sites under your domain. See this help page for more details.
If your domain's default sites visibility is set to private, and your administrators do not want to change that, you still have another option: you can share a site with a group instead of individual users. Any users added to the group later will inherit group's access to the site (or their individual level access, whichever is higher; i.e. if a group has "view" access, but individual user in the group has "edit" access, they will be an editor). Google Apps administrators can create domain-wide groups which include all users in a domain. If your domain has such a group, just add the group as editor to the site using .addEditor('groupemail#yourdomain.com') method to allow all users in your domain to edit the site. Otherwise ask your Google Apps administrator if they can create such a group.

Related

Programmatically Setting Custom Permissions for Google Sites Pages

I'm currently creating a Google Site for staff where I work. We would like each staff member to have their own page that only they can view with details such as rota's, shift itinerary etc. We would not like other members of staff be able to view this. The current idea I have for implementing this is to run a script that generates a page for each user with the custom permissions set so only editors and themselves can view it. However, although I am aware you can set site wide permissions through Google Scripts, I can not find a way to set page wide custom permissions programmatically.
Is anyone aware of a way I can do this or if there is an alternative way to achieve the same goal?
Many thanks
Check out the following link:
https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=2934
And also check out the following link (check comment #15):
https://code.google.com/p/google-apps-script-issues/issues/detail?id=1021
(comment #15): A work around you can use is to add a group with the permissions you require and then from Apps Script you can programmatically add/remove people from the group.
If you want Google engineers to develop this functionality then vote for this issue on the above link.

Google Picker API for sharing documents

I have implemented the Picker API for my Web App and there is only one inconvenient.
The App permit a user to open a project and share all kind of documents. One of the methods available to share documents with others is throughout Google Drive, so the User select the documents within its account and the App show the links to download the content shared.
All works fine but the issue is related with permissions. If other users click on any link, it indicates that he needs permission from the owner, so he must wait until access is granted.
Is there any way to avoid this? I mean, the owner share the files knowing it can be downloaded by any other user from the website.
Thanks in advance.

Change Google Drive settings in the Admin Console of Google Appsor not

Google Apps admin console has a section dedicated to Google Drive settings for all the domain. Through these you can decide if users can share or not documents outside the domain, etc. Unfortunately you cannot apply the settings to specific sub-orgs but to all the domain. However Flash Panel allows you do to this and I'm wondering which API they're using to accomplish it. I went through Google Apps Admin SDK documentation but I couldn't find anything to control or change Drive settings in the Admin console via API.
Have you got any clues about it?
Thanks a lot!
When you change these settings in the CPanel, as you noted, the setting is strictly enforced for all users in the Google Apps instance. The user no longer even has the ability to share Drive files outside of the domain.
There are no API settings that correspond to the CPanel settings. The way FlashPanel appears to be enforcing the settings is by setting up "rules" (this OU can't share with people outside the domain except for this external domain). Then FlashPanel monitors user file sharing under that OU, looks for violations and can either automatically undo the share or send a notification of the violation.
Thus FlashPanel is not strictly enforcing the sharing policies like the CPanel setting can. The user still has the option to share externally and for some period of time, the file is actually shared externally. FlashPanel simply has the ability to notifiy and or rectify the situation afterwards.

Google Doc API Single Login

Here is what I am trying to do:
Create an application which can pull down a single predefined Google Document.
Desired approach:
Create an app which automatically logs into Google Drive with the document owners account.
Once logged in the latest version of the document will be downloaded and presented to the user through the app.
This approach means that App users can access the document without a Google account.
What I don't want:
I don't want users to have to login to Google Drive themselves. I want people to be able to access the document automatically through the app.
I don't want the document to be public.
The problem I have hit:
All login approaches I can find within the Google documentation require the user to login through their Google Accounts - OAuth style for example. I can't find anyway of just hard coding the login for the single account owner into the application.
Other notes
I am creating this as a web app in PHP.
Any help or different approach suggestions gratefully received. Thanks

GAS gadget inserted to googleSite... for non-google accounts

I think this is the same as my question: http://code.google.com/p/google-apps-script-issues/issues/detail?id=852
But just to be clear: Google apps scripts won't run on a Google Site without a google/gmail user being signed in?
...are there other google products where GAS can be deployed for non-google accounts?
Thanks,
Nathan
False. You can embed an Apps Script in a Google Site using Insert > Script Gadget. Just be sure that the publishing setting is set to "Anyone, even anonymous".
You've got two different levels of user identity at work here, if not three or more. I will try to pull them apart for you in a clear way.
Google Sites can work for users of Google and non users. It depends entirely on the sharing settings for that site. If you share it with the world, it will be shared and indexed by search engines. If you share with anyone with link, search engines won't index it but no user will have to sign in to use the site.
What you are embedding in a Google site may have it's own user identity issues. The easiest way to manage these is to go into 'Publish' menu, and 'deploy as Webapp'. You will then see a menu that asks which account the script should be run under, essentially you or the user. And then which people to allow access, which you would select 'Anyone, even anonymous'.
This will run that app as your account, but allow anyone to call it. Works great for allowing the public access to a form created in GAS.
Now the other problems. It may be possible for you to have code in your GAS that specifically calls for a user. In that case all of the prior settings don't matter. When the script looks for a user and finds nothing valid it will error. These call are pretty obvious though and are more rarely used. (At least in my experience.)
But, in short, yes! You can certainly embed GAS into Google sites to be called by anonymous users.
Example of mine: https://sites.google.com/site/greenmountainretreat/sign-up
The issue you are referring to is about inserting i-frame gadgets into non-Google sites... please don't confuse things... and read the issue report thoroughly.
If you want another example...