I'm using a Google spreadsheet as a template that is copied at form submission. This spreadsheet has several custom functions.
I've run into two problems on spreadsheets copied from the template:
A custom menu function that allows the user to create a PDF of the active sheet cannot be authorized from the front end -- it simply hangs. It appears oAuth authorization can only occur from the code editor, which I can't expect users to do.
Users will click a custom menu function, get the authorization dialog, authorize, then forget to click again to run the function.
Is there a way to have users authorize all functions, including oAuth (for PDF creation), as soon as they open the sheet?
Just in case someone else happens upon this, I think I found my answer:
It appears that functions using oAuth can't be authorized from the front-end. It also appears that Google has no intention of making it available in the future unless you want to write your own authorization flow. I, for one, do not.
I did, however, find a work-around. By including the functions that need authorization in a library and including that library in your script, users only need to authorize a function once, no matter how many spreadsheets call the function.
There are only 12 users in my organization, so I got off easy on this one -- I can go to each of their computers and authorize the functions in the library once, and that's that.
Hope this helps someone!
Related
I am currently making a Google Site where I would like to embed my contacts. The contacts I am referring to can be found if I log into my gmail account and click on ->Mail->Contacts on the upper left hand corner. Then, on the next page, I click the "Other Contacts" link.
I have tried using a google spreadsheet to read in this data and then displaying that in the Google Site. However, I ran into a few issues. I tried the IMPORTHTML("https://mail.google.com/mail/u/0/#contacts/group/26ae/Other+Contacts","table",1). This didn't return anything. I tried to change the second parameter to 'list' and for the third parameter, I went up to 30 so I doubt that is the issue.
I also tried this approach but no luck. https://www.import.io/post/how-to-get-live-web-data-into-a-spreadsheet-without-ever-leaving-excel/
What would be the best way to resolve this issue of getting those contacts to show up in my site?
I see three options:
Export your contacts to a CSV and import that into a sheet. The downside is that this is not syncing, it is a static update, so maintaining contacts can be problematic.
Use this addon. I have never used it and can offer no advice either way. I believe your domain Admin will need to set it up and I do not think it populates a spreadsheet, so you won't be able to embed your contacts.
Write a custom Google Apps Script. The benefit here is you could use a script to also display the contacts in a clean fashion, with the name as a link, or otherwise. The downside here is you need to write a script. It is javascript based so if you have someone who can do that, it may be your best option. I have done this for a staff directory, which lists all of our domain accounts:
How would you tackle the following problem, using Google Sheets:
User A and B bot need to submit an input (some text) to a shared sheet. The input must be hidden from the other user until both have submitted. Both users can change the input until the reveal, but not afterwards. Think of it as simultaneous action selection, except it's on different time zones so we can't just shout one two three go.
Currently, we are using salted hashes. That is inefficient and time consuming. I'd like to automate it. However, I don't know of any tool inside Google Sheets that allows you to hide inputs from other users under certain conditions, or anything that locks the input after both submit either (the submission shouldn't be tampered with unless both users agree, unless it's done before the other user submits).
This might need to be done with external coding, and I'm up to that (although I currently have no idea how to integrate it in google sheets). However I have never programmed something that read input from anything other than a terminal (or a txt file that one time it was required in class) so please provide some reference for that too. :)
Many thanks in advance!
Use a Google Form as the input tool. Then after both users have sent the input, share the spreadsheet with them. This could be done manually or with Google Apps Script.
References
Create a survey using Google Forms - Docs editors Help
Extend Google Docs, Sheets, and Forms with Apps Script - Docs editors help
I have been trying to fully understand the Google APIs so I can grab data from a Google spreadsheet that is private using Javascript.
I am using jQuery and D3.js to create a chart and I want to seamlessly pull the data without the user being redirected to an authorization page. I know I need to use OAuth, but I can't find any examples of how to do this seamlessly through an AJAX call.
https://developers.google.com/google-apps/spreadsheets/#authorizing_requests
This doesn't mention anything that makes it seem like I can do it without an OAuth dialog to the user.
To get a private spreadsheet page, you're going to have to authorize. See Google Spreadsheets API with OAuth 2.0 for Javascript for a complete working OAuth call for a Google Spreadsheet. I used this to create a working database using Google Spreadsheets.
Another way that might work: Fusion Tables. You will have to have a public sheet, but you can make it unlisted meaning it is only available through a link (which you only use in your javascript). It might want a location (as it was designed for spatial data), but you might be able to get around it or just use a dummy value.
While https://developers.google.com/accounts/docs/OAuth2Login is very descriptive, I cannot seem to wrap my head around how to translate into a Google Apps Script.
The ultimate goal is to have the user click a link, authorize access to their userinfo. I will then use their email address or userId to assign the appropriate spreadsheet to other Google Apps Scripts UIs.
I am certain that some sample code would get me on my way.
Is it even possible?
Can a linked be utilized to make this happen? http://support.google.com/sites/bin/answer.py?hl=en&answer=1224166&topic=1224152&ctx=topic
The trouble is that when you publish your script as a service, it executes under your ID. All the authorization has to be done in the script editor. So, when a third person clicks a button or link or whatever, the script runs under your user ID and all you get back is your own user id.
In short, the answer is no. Sad, but true :(
Check out the OAuth code on the Google Code site. There are some great examples along with the client (and server) code in several different programming languages. Follow along with the samples on how to get the tokens needed.
I am creating an ios app that needs to download a html page and extract some information from it. To get to the page I also need to login. I have looked everywhere for some code on how to login to a site using the cocoa framework, but every answer I see only seems to answer half the question. Here is the login site: romres.ist-asp.com. I need some code for writing something in the first field (the other two are left blank), then submit the form and then I need to be able to see the next page. I believe apps like Facebook should use som of the same technology, where you log in to a facebook and then you can see the contents of your profile.
Basically what you want to do is called scraping.
Scraping is really easy for sites that don't require authentication, but in your case what you should do is to inspect the POST request being made when logging in the site your interested in (try to understand of the service respond) and the POST request made, when already logged in, to retrieve each page.
The purpose of all of this is to have later the possibility to simulate regular HTTP requests that should came from a browser via code.
If you have any doubt ask in the comments.