Using API to get access_token and now I need to open Google Sheet.
Step 1.
Authorization: Bearer ya29.a0AV...." together with link: "https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit"
Step 2.
Now HTML document back (~200kb). I'm using libcurl for that.
The problem is - missing are some css and js files and I see document just partially. Is there any way to open/edit Google Sheet using API?
I know for the option to just open https://docs.google.com/spreadsheets/u/0/d/[DocumentFileID]/edit in the new browser tab, but in that case I need to manually login to Google and that's what I try to avoid, because I want to use API to login and to open/edit a Sheet.
I also know for the option to share a document but I also try to avoid that. I'm writing application to customers who can access they own documents once they confirmed API usage.
I think you may have misunderstood what the google sheets api can do
The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data.
It gives you access to the data, it does not allow you to open the google sheets web application. Your going to have to code your own google sheets type app if you want users to open sheets directly.
Related
I am collecting Data via Google Forms, they go into a Google Spreadsheet.
Then I would Google Apps Script to enter the Data into a Webpage Formular.
Is this possible in anyway with Google Apps Script?
Update:
I would like to do Google Apps Script, go to a website( I don’t have control of the website, then get data from a google spread sheet and enter it into the fields then click on certain fields. I know I could to it via puppeteer. But I was thinking google Apps Script has something/sometype to interact with websites.
Not in the way you're thinking. If the target website is not secure you can "fake" a form submission on it by making a POST requesting using UrlFetchApp. But this will most likely not work on most sites.
You can use UrlFetchApp to get the target website but GAS won't render it or let you interact with it like puppeteer will.
I have Google spreadsheet with script attached to it (with the Tools->Script Editor tool).
I want to call one of script function from external Android App. Is it possible? Should I use Spreadsheet API?
Unfortunately, you cannot directly call your script from any external application.
However, you can change it to be a web application, then invoke it via an HTTP GET or POST from almost anywhere, including an Android app.
Insert new rows into Google Spreadsheet via cURL/PHP - HOW? provides an example of a web app that you could adapt.
Should I use Spreadsheet API?
Your question doesn't actually say what it is you want to do, so the answer is "it depends". You still won't be able to invoke an embedded script using the Spreadsheet API, but you will be able to read and write spreadsheet content.
Obviously the answer depends on your usecases, but have you checked the Google Appscript API?
As stated it
provides methods to remotely execute Apps Script functions
I would like to programmatically create google spreadsheets that have some columns marked as 'read-only'. Using the web browser client this is straight forward, but I have not found any documentation on how to do this via the API. Is it possible?
You won't be able to do this by relying on the Drive API exclusively. The good thing is, there is a Google Sheets API. This will allow you to access your Sheet file and edit its content. More information can be found on this resource: https://developers.google.com/google-apps/spreadsheets/.
We are finding a new behavior in the export API between new google sheets and old google sheets.
It is also somewhat unclear exactly where the endpoints are supposed to be- my understanding is that everything should move to the drive API eventually.
So, what we are doing is first getting the information for the document using:
https://www.googleapis.com/drive/v2/files/
This works fine, and we get all the info.
Within that, we have the export links that look like this:
"exportLinks": {
"text/csv": "https://docs.google.com/spreadsheets/export?id=&exportFormat=csv",
"application/pdf": "https://docs.google.com/spreadsheets/export?id=&exportFormat=pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=&exportFormat=xlsx"
}
Directing us to use the docs.google.com endpoint, which we do.
When we use the "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" link (excel format) this works fine for OLD Google Sheets.
However, for new google sheets we get a redirect to an endpoint that is in our Google Apps domain of the format like this:
https://www.google.com/a/.com/ServiceLogin? etc.
We have put the OAuth token in the header, again, this works fine with old sheets but not with new sheets. If we remove the token, then it redirects us to yet another signin page.
Why is it redirecting rather than returning a 403 unauthorized if there is an issue with the authentication? Why only for NEW sheets not old?
This results in some HTML being returned, not the file- as if we were a browser.
So the question is two fold-
1) how do we download new sheets in excel format programmatically using Oauth
and 2) If its different than old sheets how do we detect which is which so we can support both?
This is an alternate to the Google Maps V3 Full Integration API issue in my previous question.
I would like to give the user the ability to click a button, that then creates a new Google Spreadsheet, within their Google Drive, that allows them to save the data (JSON) that has been created while playing with my Mapping Application, into the new spreadsheet.
Later, the user can go to their Google Drive, open the spreadsheet, click a menu, open and populate my Maps App with their data from the spreadsheet. The user can edit the data either in the Spreadsheet or the Map and the changes go both ways.
Basically, I am looking for two way data binding between Google Maps V3 API and Google Spreadsheet that is very easy for a non-technical user.
It would seem that I should be able to write a GAS function and access it from my standard web page. How do you do that?
If I could convert my Maps V3 API app to GAS, the issues would be trivial, but until then an alternate workflow between Maps and Google Drive would be very helpful to allow users to save / collaborate their work.
If you deploy your Apps Script project as a web app you can have your application make requests to it over HTTP. The doGet() and doPost() handlers can both read request parameters, and using the ContentService you can return JSON or XML data. Likewise, inside Apps Script you can use UrlFetchApp to make HTTP requests to your application.