Sharing Google Drive Realtime Documents - google-drive-api

I have created a realtime document on Google Drive. When I attempt to share this file with someone who doesn't have my app installed, the file shares successfully, but when they click the file it says "Sorry, no preview is available".
This realtime document is a shortcut file. How do I get it to prompt the person to authorize my app?

I'm using the Realtime Playground as my example as I'm not sure of the specifics of your application.
App authorisation
When you created your application you visited the Google API Console and created a project with Drive API enabled. At some point you copied "Client ID" from the Google API Console into you application ID code.
In the realtime-playground case APP_ID is set in the javascript file rtpg.js (you might not be using JavaScript but there will be an equivalent step for other languages).
rtpg.APP_ID = '840867953062';
File creation
I believe that any drive realtime document/shortcut you created with your application will contain a reference to the creating application (mostly likely in the form of the client/application ID you obtained above).
File sharing
Once you can see your newly created Google Drive Realtime document/shortcut you can share this with somebody else using the normal Google Drive sharing methods. At this point they can see it but cannot do anything apparently useful with it. This is where I believe your application may differ from the realtime-playground example.
Integration with Chrome Web Store
On the GitHub repository for realtime-playground you'll notice a cws (Chrome Web Store) directory containing the stuff necessary to deploy the realtime-playground as Google Drive application in the Chrome Store including screenshots to be used. If you look at the manifest.json file you will see another reference to the client id:
"api_console_project_id" : "840867953062"
So if I share a realtime-playground file with somebody who doesn't have it installed, then clicking on the file in Google Drive will result in a "Connect app" popup which will try to locate the corresponding Chrome Web Store Drive app (using the common id as the key) and this will show something similar to what you might see if you found this application directly in the Chrome Web Store.
The manifest.json also contains:
"app" : { "launch" : {
"web_url" : "https://realtimeplayground.appspot.com/" } }
which tells Google Drive what to do when the installed app is called.
So my guess is that your application doesn't work like this as you don't yet have public visibility of your app in the Chrome Web Store.
See also: Create a Chrome Web Store Listing
I hope this helps.

That is fine. If you open your eyes, you will notice that Playground demo does not provide any preview either
Yet, you see, the associated app is available. You can click it and open-with works normally. Your app-created files operate similarly. They are associated with your app by default. You can open them by open with rather than by preview. Can you? No, you cannot. But that is another question.
Otherwise, I see no cleverness in associating your file with chrome extension rather than with your app.
How do I get it to prompt the person to authorize my app?
I recently had a similar question. Instead of linking your files with extension in chrome, pass the direct link, like http://your-app#fileId=..., as playground demonstrates to your shared fellow if open-with fails.
The preview seems to be another story.
Wait, Do you mean that I need to create a new fresh account to test how your file is unassociated with your app? How do you preview the files in your primary account? If you know how to preview you may answer my question, at least partially. But why do you associate authorization with preview?

Related

google drive hosting changes in URL

I've developed a web app that uses google drive as hosting platform as explained here:
https://support.google.com/drive/answer/2881970?hl=en
The application has been working OK when users accessed:
https://googledrive.com/host/0B0YWdwxH6K5XdVpaNjhWUl9vZkE/?scriptid=AKfycbx66sZMaqLK8byhV7wY_DoQ8ouqF1acWRcc0JIHyDu5CVWZupAK&id=people
But yesterday it started redirecting that address to:
b216bdb4cf56e8d9d85cf1123921ca125a010325.googledrive.com/host/0B0YWdwxH6K5XdVpaNjhWUl9vZkE/
any idea why? is this a permanent change? does the subdomain key follow any logic?
Browser: occurs on chrome & IE
Operating System: windows8
Drive on the Web / Drive for desktop: when accessing googledrive.com/host
I found the right thread at google.com to answer this. Here it is: https://productforums.google.com/forum/#!category-topic/drive/mTyJXruRhBg
In short, the redirect and prefix is here to stay. It's for some security thing. All files within the same googledrive folder will be prefixed with the same guid-looking string. That is, provided we use this googledrive url form: googledrive.com/host/{folderID}/FriendlyFilename. Then, any support files you want to access or link from that folder, just access them as FriendlyFilename with relative url form.
My problem was, I was using the obscure form googledrive.com/host/{userID+fileID}. (no FolderID or FriendlyFilename). That now gets a different domain prefix for every file within the same folder.
Here's a different variation of that test file I showed above (which was getting Security exception for webworker). It works now by using the {FolderID}/FriendlyFilename form. Tada. https://googledrive.com/host/0B8BLd2qPPV7XME1rNU9iWnYtbTg/ded-worker-F12throw.html

Google drive sdk app not showing in open with list

I have a google drive app. It is setup to be a drive app and the open url is given in the app details.
Everything works well, but for some reason when the user installs the app it is not displayed in the "Open with" list of apps.
the app is setup to use google documents and docx (this is given in the default mime types).
I also had pdf in the mime types and it was working for them I switched it off and it was correctly turned off.
Any idea why an app might not be showing up in the "open with" menu by default?
Please get back to me as this is having a huge impact we are getting a lot of questions from users that are not being able to find the app..we have over 1000 installations already.
The app also has a launch icon setup on the manifest file. I don't supposed this affects it's behaviour on drive?
"launch": {
"web_url": "http://mail.google.com/mail/"
}
Best regards,
Joao Garin
Have you enabled both the Drive API and the Drive SDK in the Google Developer Console?
See the details on enable the drive platform and make sure you have everything configured properly.

Determine if a certain File is process by a project that uses Google Drive API

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.

Get listed in Google Drive Apps Collection

I have released an app for Google Drive in the Chrome Web Store. I thought it might get added to the Google Drive Collection automatically, but that didn't happen. Is there any form I have to submit?
For your application to appear in the collection of Drive apps your Chrome Web Store app's manifest file need to specify the Google Drive container and your API console project ID as described in this document.
Then your app's listing should get the "Works with Google Drive" badge and, given a few minutes delay for indexing, your app will appear on the collection of Drive apps.
Beware: you may not see it there as a listing doesn't appear for you in that collection if you have already installed it on your browser. It will appear to all other users who have not installed your app yet. To make sure it's there: try looking at the collection with another browser (FireFox for instance).

I am facing "The authenticated user has not installed the app with client id" error even after installing the app [duplicate]

I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error:
"The authenticated user has not installed the app with client id ..."
Reading further, it seems I need to publish my Emacs application in the Chrome Web Store to get access to the Drive API. That doesn't make sense to me...I noticed that there is a FUSE project in development for Google Drive, which suggests that native development is possible. When I skimmed the code, however, I didn't see a Chrome Web Store component to getting it working.
Am I trying to misuse the API, or is there an route to make this work that makes more sense?
EDIT:
According to Ali Afshar, of the Google Drive team, installation is no longer required to use this API. So what follows may no longer be relevant, but will be left for historical purposes.
So, first off the API does not support application development in the sense that we are both doing it, I wouldn't use the word native though. The good news is I have been doing some research and Google Drive is really just a rebranding of Google Docs. So the Google Docs API could be a good choice as well for the same purposes.
Anyway, here's the steps to solve the error: "The authenticated user has not installed the app with client id ..." Which is a 403 error, for the sake of this answer. These steps assume you have set up an app in the chrome web store as is required, and installed it. I am working on my local machine too, with my project: http://github.com/tom-dignan/gdrive-cli which I have gotten past this error, so I think you should keep plugging away at your emacs version, because I think we can make this work.
a. Open the Google APIs console.
b. Confirm you've already enabled the apis under "API Access" both the API and SDK for Google drive should be enabled. There you get your client secrets/api keys and such. I am almost positive you've done this already, so go ahead to C. (this is here for others who may have missed it)
c. In the left navigation bar, under "Drive SDK" you will need to do the following:
Add a "Support URL" (required)
Add at least a small 16x16 application icon (required)
Add "OAuth Client ID (Required)" under Drive Integration (I was just tinkering and this seems to be the key field.)
Add "Open URL (Required) URL to open for your app from the google drive UI."
Check off "Multiple File Support"
Add some MIME types and file extensions, "text/plain", and txt for example
Add the the auth scopes:
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
Don't bother trying to add the auth scopes for Google Docs here, because it won't work. Google does not want us to use it that way because files that drive apps create should be private to that app. Integration with Google Docs will have to be separate.
Now I know you must be thinking "why do I have to add some of these..." It's because the form makes them required fields. In mine, I put a couple URLs that point to static HTML pages.
Once you've done the above, clean up your state and reinstall your chrome app. Then try your code again, and it should stop giving you a 403.