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.
Related
I'm using multiple Google accounts. In one of them (not default) I created Google Spreadsheet file and I want to create Script connected to it. Nothing complicated. But the problem is that after clicking Tools > Script Editor I'm being redirected to default user or I see this screen:
The same problem I have when trying to use: script.google.com
What can I do to enable Script editor?
I know you asked this 9 months ago, but here is my solution;
Sign out of all google accounts except the owner of the spreadsheet
You can now access the scripts and macros pages (go there)
Create a bookmark of them (this saves which profile is logged in)
Now sign back into all your profiles
Voila!
You will be able to access the scripts or macros via the bookmarks without getting the error page.
This is a reported bug.
Go give it a ☆ if you want to let Google know that this affects you.
You can consider appending authuser=email to the URL to open the script with a specific Google account.
For example, script.google.com...?param=value&authuser=email#example.com
I was not able to reproduce the problem. Perhaps it's a glitch or there is something wrong that requires some troubleshooting techniques that are off-topic on this site.
As a workaround, for the account having problems, use another Google Chrome profile, Incognito mode, or another browser.
By the other hand, it's possible that there isn't any wrong and it's just something related to your specific scenario.
From Sign in to multiple accounts at once
Sometimes settings might carry over
If you're signed in to multiple accounts at the same time, sometimes we can't tell which
account you're using. For example, if you're signed in to two accounts
and you open a new browser window, we aren't sure which account you
want to use. In cases like these, Google might apply settings from
your default account, like its Web & App Activity and Ads
Personalization settings.
google's default account (the first one you sign on with) has to be the owner of the sheet
Based on #iansedano's answer, you can share the file with the default chrome user and open the same link in a new tab again to resolve the issue.
If someone needs a quick fix for this :
At the end of the url change the "authuser=1" by the index of the Google Account you want to log with. (0 is the first one, 1 is the second)
https://i.stack.imgur.com/qJows.png
You can also open a new incognito window, paste your sheet url there (you'll need to authenticate). Then you can open Tools -> Script Editor
I was wondering if it is possible to show/hide links on the sidebar navigation of a Google Site based on what the email / permissions the end user has. Has anyone ever done anything like this? I don't see any options under "edit site layout", perhaps it can be done with Google Apps Script? If anyone has any resources / links to similar problems and solutions, that would be appreciated. I can't seem to find anything on the subject myself.
Users will only see pages they have access to, so you can set individual page permissions and this will hide the page from some users. I use Google Groups to define the permissions and add users to the appropriate groups. If a user is in a group which has permissions to view, they have permissions to view. If they are in a group which has edit permissions, they have edit permissions. They will get the highest permissions associated with all the groups they are a member for which is applied to that page.
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.
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...
I would like to write a GoogleApps script that accesses a website, logins using my credentials, makes a selection from a drop down menu and copies the displayed values to paste them on my active spreadsheet.
Is this possible or should I go about it a different way?
Directly, that is not possible. However if the website offers an API or if the website makes use of URL parameters to pass information about what you've selected, it might be possible if the website also uses HTTP authentication.
Absolutely possible. Capture what you need to do for authentication. Repeat it with Google Apps script.
Capture what you need to do with the drop downs. Repeat it with Google Apps script.
Quite generic instructions, but you didn't give any more specificity to your problem. Use something like TamperData addon for Firefox to capture/see what Google Apps Script needs to pass back and forth to the server.