Search code examples
google-drive-apifile-sharinggoogle-drive-realtime-apimultiple-accountsgoogle-realtime-api

Sharing the Realtime Documents


I have created a playground application. I see that it creates shortcut files in my google drive. I tried to share it with incognito (because I want the doc to be available to anybody and do not know how to create another google account, so I log out into incognito). The shared link looks like https://drive.google.com/open?id=0B00--A0eRH1JLTdsX2t0LWw5RE0. But, incognito fails to view it. It says that "No preview avaialable" in what is supposed to be its google drive window and offers the log in

enter image description here

The key problem that I see is that playground application has the following structure, which comes from the official demo

function onAuthorized() {
    function onFileLoaded(doc) {display(doc)}
    gapi.drive.realtime.load(your_doc_id, onFileLoaded)
}

// App entry point -- start by authorization
gapi.auth.authorize({
    client_id: rtClientId, scope: ['install', 'file'],
    //user_id: userId,
    immediate: !popup }, onAuthorized
);

which seems to demand authentication in the first place before displaying any doc. Authorization is problematic for the unsigned mode that I want my app to be available. I want to share a file and make it viewable to the general public, without the need to log in. This raises a question if incognito users are able to view or event edit my document. I also concern how to copy the doc to their account if desired: one thing is when you have created a file on your drive with my app, you can probably list the files and use drive.copy api to copy desired one and other thing when you want to copy a file that is not available on your google drive and the only thing you have is its id.

BTW, can you tell me which account to use for non-incognito testing from another account? If I create the document in one account I want to see how it looks/accessible from the another.


Solution

  • The Realtime API does not provide anonymous access by default. See https://developers.google.com/google-apps/realtime/faq#does_the_realtime_api_support_anonymous_access