We are building a web application that should get all files from a specific folder in our Drive (read only). The problem is that I can't find a way to access our files without using OAuth. Basically I would want to request our files using AJAX and present the contents of them on a page (without the user having to do anything). Is this at all possible and have I missed something?
Whenever I try something without using OAuth I get a global internalError (being related to authorization according to the current documentation).
The experience I'm trying to achieve:
User enters http://domain.com/posts > Get all public files from folder Y > Sort them by date > Show the titles in HTML > User clicks title > User is presented with full contents of the file as HTML.
Is this possible?
Thanks in advance! :)
UPDATE: To clarify: I would want to depend on our API key only.
Related
I'm writting Web application to display content of Google Drive images and files, using API.
Currently, I can only see thumbnails of images/files (without login to Google drive).
If I want to preview the file, I need to be logged into Google drive and then I can use link returned by "webViewLink" and actually see the file.
I know I can click on folder or file on Drive and Share it, but I'm afraid that my customers will not be able to do that and it is complicated, anyway.
I already displaying Google dialog to customer where customer need to allow access to upload,delete etc. of files and now he can not preview the file???
Application is designed to display image/whatever to customer only, inside app only and not to sharing. With other words, I want to display images which he can see anyway if he is logged to Drive.
Is there any other option to allow customer to preview the file, if he already allowed full access previously?
Thanks.
Authorizing with OAuth does not automatically log you in. Users use their credentials to give their permission to create an access token, which needs to be used in any API calls. It does not imply that a browser session was created, that's a separate process.
You'll notice that the webViewLink is just the regular Drive URL with /view at the end. It's a page that requires the user to be signed in:
"webViewLink": "https://drive.google.com/file/d/<FILE-ID>/view?usp=drivesdk",
I'm not aware of any methods to sign in the user at the same time they use OAuth, but if you send your access_token in an Authorization: Bearer <access_token> header when trying to access the above URL you can see the preview without having to sign in. Depending on your platform I think implementing this would be tricky, and maybe not possible in Apps Script alone.
My recommendation as a workaround is to just use a full thumbnail. Don't know if you're aware of this, but the thumbnail URL has a =s parameter at the end that defines its height in pixels:
"thumbnailLink": "https://lh5.googleusercontent.com/<THUMB-ID>=s220",
You can change the default =s220 at the end to a higher size or remove it completely to get pretty much the full size of the image or PDF page. This may be enough for your users to figure out what the file is.
I'm new to the Google APIs, and would like to write a small service class for my web application that:
creates blank Google document without user assistance
assigns a generated title
returns a URL that can be provided to multiple people to edit this document
This document mst be editable via a sharing link. Ideally it is owned/managed as part of the web service's Drive storage.
Code is welcome if it's easier than explaining, but I'm really asking for help understanding Google's service offering.
Can I fully authenticate using only credentials specific to my app? (e.g. call the Drive API without prompting an interloper/observer/user to
authenticate.)
Once authenticated, can I create documents local to my
API?
Whose quota are the created documents consuming, the person that created the API key?
Can I share
these created documents with others?
Will I be able to manage a list of
these created file URLs from a standard Google web UI?
Just to clarify what it is that you are asking. You want to be able to embed a google doc on your website A couple things that can happen here.
First, you will need to create a google doc, lets say a spreadsheet. Within that spreadsheet you will:
click File > Publish to the Web.
From here a new window will be brought up. Click Embed and Published content and settings and click the publish button. Ensure the Automatically republish when changes are made checkbox. (this will allow for your website to be automatically updated anytime that doc is changed.
Take the embedded link that is generated and plop it in your webpage and it will be live.
Now you can share the page via Google Docs and anyone that has that link can make changes to that spreadsheet. As soon as a change is made, it will update on your website with the next refresh.
Hope this is all clear, let me know if there is anything unclear.
Cheers
I have a collection of PDF files on a Google Drive. I have shared them and I want to be able to link to them from a list on a web site. What I'd like to be able to do is work out the file name of the PDF using information in the list. As a simple example, if my list contains items 1, 2 and 3 I'd like to be able to upload PDF files 1.PDF 2.PDF and 3.PDF to Google Drive then have the web site just link to those when a link is clicked and show the PDF files in the browser.
So, I guess I could do this just by uploading the PDF to Google Drive and manually adding a link to PDF on the web site. However, what I want to do is generate the link programmatically so that when I have, say, 50 PDF files I don't have to keep getting the link from Google Drive and adding it to the web site. The site should just work out that item 50, say, in the list will link to 50.PDF, for example.
I've tried to get the file id using the API but that requires the authorization token to be generated and manual intervention to take place, so that won't work. At least, not at the point where the file is viewed because the viewer is anonymous.
So my questions are:
Is it possible to work out what a file name will be on the drive using just something like an item number in a list?
I guess that there are maybe some other options - for example, when I add the items to the list on the web site programmatically, I could go and locate the google drive file manually using a web application and link it using the file id at that point. I could store the ID in a database - however, would any anonymous user then be able to just click on the file link on the web site and view the file?
Finally, can anyone think of another way to do this?
Any help would be appreciated! :)
Is it possible for you to use a service account? You can authorize the app with an account dedicated to your app and user doesn't need to authorize and authenticate. The files you will be uploading will be managed under the service account's Drive.
You can learn more about service accounts on https://developers.google.com/accounts/docs/OAuth2ServiceAccount
If you have implementation specific questions, please ask.
We are building a web application that should get all files from a specific folder in our Drive (read only). The problem is that I can't find a way to access our files without using OAuth. Basically I would want to request our files using AJAX and present the contents of them on a page (without the user having to do anything). Is this at all possible and have I missed something?
Whenever I try something without using OAuth I get a global internalError (being related to authorization according to the current documentation).
The experience I'm trying to achieve:
User enters http://domain.com/posts > Get all public files from folder Y > Sort them by date > Show the titles in HTML > User clicks title > User is presented with full contents of the file as HTML.
Is this possible?
Thanks in advance! :)
UPDATE:
To clarify: I would want to depend on our API key only.
You can do it this way, without using Google Drive API:
Make the folder public
Copy the folder ID from the URL
Append it to https://googledrive.com/host/ e.g. https://googledrive.com/host/0BzEbtMoF6IXbaVN2Qmx1em9qS0k/
You will get a directory index with all files listed and if the (sub)folder contains an index.html file, it will be rendered instead.
To get the JSON or XML file list, use YQL.
Good day! I am currently developing a website using Google Drive API. However, I am wondering if is it possible to know if a certain file is created/uploaded/shared by the project using an App Id. I was thinking if it is belong to the attributes of a file. But, when i checked, it seems that, there's no such thing.
What I am trying to do, is to filter the files' shared by the other user to the owner of the account using my web site. Is it possible? Any suggestions on how to do it?
Thank you in advance.
File metadata doesn't contain this information unfortunatelly, therefore you can't know if some file was created by your app or not. But FYI Google store it somewhere, if you will try to upload somefile without providing its content type (* / *) and after that try to open this file through browser you will see the message:
No preview available
This item was created with YourAppName, a Google Drive app.
Download this file or use one of the apps you have installed to open it.