Create presentation with entire JSON on Google Slides API - json

Hello everyone (sorry for my english)
I have a problem with Google Slides API, I need to duplicate a Google Slides Document from an account to an another (so I can't use Google Drive API with the function "copy").
For that, I used Google Slides API to retrieve a JSON Object (Presentation) on client-side and send to my server (nodejs).
In my server-side application, I send the Presentation Object to anyone and the client can store it in Google Drive (always with Google Slides API).
But the problem is when the client send the Presentation Object (with all fields) to Google Slides API (presentations.create method), it just create a naked Google Slides document without properties include in my requests.
I need to store an entire Google Slides document but I can't do that and I don't know why.
I spent all day with this issue, please can you help me :) ?
Thank you !!!

The Slides API only creates empty presentations via presentations.create(), unfortunately. Only the title is taken from that input object.
For a cross-account copy, Drive's copy API is likely your best bet. If you have write access to the source presentation in Drive, one option is to share it with the destination account first using the Drive permissions.update API and then using copy. Another option is to try an export then import.

Related

Using ApI is it possible to edit or open Google Sheet?

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.

Automating Google Slides production

I'm wondering if there may be a way to programmatically create presentations in Google Slides. So for example if underlying data changes I can just refresh the deck without lots of copy paste for all the charts etc.
Something similar to using like markdown and R slidify to produce data driven PDF presentations. My end product needs to be a nice pretty Google Slides presentation.
Is this the sort of thing I could use the Google Drive API for? I'm not sure if App Script can be used for Slides like you can for Sheets.
Am hoping it's a common enough problem that a solution exists.
One option is to just automatically produce a PDF and then manually import into Google Slides. Problem is that this approach is a bit limited due to errors on conversion and lack of other Slides functionality.
Any input much appreciated.
It's 2018, and great news (and answers!) to this older question:
The Google Slides REST API launched in Nov 2016... here is its launch
post and 1st developer video I made to get you started. A shorter code sample than the video's is the Quickstart in the docs (available in a variety of languages). If you're new to Google APIs, I recommend you watch this video, then this one, and finally this one first to get an idea of how to use them. The code samples are in Python, but if you're not a Python developer, just pretend it's pseudocode because many languages are supported by Google APIs Client Libraries. :-)
If you code in JS and want to have Google host+run your app, the Slides service in Google Apps Script launched in Sep 2017... here is its launch
post and 1st developer video I made to get you started. This is also the same technology behind Slides Add-ons. If you're new to Apps Script, I recommend you watch this video to get an idea of what it is and how to use it. Then check out its video library for more examples of using Apps Script. (Admittedly, it's easier to code w/Apps Script vs. the REST APIs, making it more "addictive" for developers... you were warned!) :-)
Additional videos on programmatically accessing Google Slides can be found via its developer video library. Videos on this and other G Suite developer technologies can be found in the G Suite Dev Show series which I produce.
There's no video for this, but there's an open source Markdown-to-Google Slides generator (written in Node.js) my colleague created that you may be interested in, representing one of the "reference apps" using the Slides API. You can find more about this app as well as others on the Samples page of the documentation.
No video for this either, but Node.js developers who want to get up-to-speed quickly learning how to use this API should try the Slides API codelab where you build an app that uses Google BigQuery to analyze open source licenses and generate a report presentation... letting you learn TWO Google Cloud technologies with one tutorial! :-)
The Google Slides API was launched on 11/9/2016. It provides the ability to read, create, and edit Google Slides presentations.
At the moment there still isn't an equivalent service in Apps Script, but you can use the Apps Script OAuth2 library and UrlFetchApp to make calls to the API within a script.
Requested feature, follow https://code.google.com/p/google-apps-script-issues/issues/detail?id=1573&q=presentation&colspec=Stars%20Opened%20ID%20Type%20Status%20Summary%20Component%20Owner for updates.
An example from Apps Script:
Enable the Slides API in the developer console:
Click on Resources > Developers Console Project > [Your_Project_Name].
Click on Enable API, search for Slides and enable the Slides API.
Use UrlFetchApp to send authenticated requests to the Slides API
As a simple example from within Apps Script, consider fetching the latest version of a Presentation (presentations.get).
// Add your presentation ID
var presentationId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Force add the Drive scope (as this comment *will* get parsed
// and trigger a popup to authorize Drive access)
// DriveApp.createFile('')
// URL formed as per the Slides REST documentation
var url = 'https://slides.googleapis.com/v1/presentations/' + presentationId;
var options = {
headers: {
Authorization: 'Bearer ' + ScriptApp.getOAuthToken()
}
};
var response = UrlFetchApp.fetch(url, options);
// Turn this back into a JS Object so it can be used.
var presentation = JSON.parse(response.getContentText());
// Log the ID of the presentation
Logger.log(presentation.presentationId);
// Log the number of slides...
Logger.log(presentation.slides.length);
// Loop through the slides
var slides = presentation.slides;
slides.forEach(function(slide) {
// ... do something with each slide...
});
The structure of presentation is also documented in the REST reference. Armed with the REST reference, this example can be extended to be used with any Slides API request and response.

Is it possible to protect google spreadsheet data using the web api?

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/.

Using Google Drive contents using Google Drive API without sending access tokens for each request

I am writing an application that can modify an spreadsheet in Google Drive, but the problem is that each time I try to access Drive contents it asks for access token as per the OAuth2 specification which I have to generate manually after browsing through the following link:
https://accounts.google.com/o/oauth2/auth?access_type=online&approval_prompt=auto&client_id=<THE_CLIENT_ID>&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive
Anybody having idea if its possible to either get this token through Drive API or through any other medium, The client application will be in the form of a Java Swing application in which there will be text fields the text inserted in those fields will be added as a row in the spreadsheet hosted on the Google Drive.
Thanks
You need to get the token manually the first time, but then you can reuse it. I guess this is a duplicate?
Stored Credential from google api to be reused java
must I click "Allow Acess" every time I connect? Google Drive SDK API
[EDIT] Sorry, I did not see the date.

How to Access / Run Google Apps Script (GAS) Functions from ordinary non-GAS web apps?

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.