Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbviewer can't render files in Google Drive #427

Open
Sisyphuss opened this issue Mar 18, 2015 · 8 comments
Open

nbviewer can't render files in Google Drive #427

Sisyphuss opened this issue Mar 18, 2015 · 8 comments
Labels
tag:Provider Related to a notebook provider type:Enhancement A proposed extension to the behavior of the project

Comments

@Sisyphuss
Copy link

Nbviewer failed to render a valid Julia notebook:
https://drive.google.com/file/d/0B30Cah_MN0i0TlZfRlBXLWgxbE0/view?usp=sharing
stored in Google Driver.

@bollwyvl bollwyvl added tag:Provider Related to a notebook provider type:Enhancement A proposed extension to the behavior of the project labels Mar 18, 2015
@bollwyvl
Copy link
Contributor

Well, that link doesn't resolve to a notebook, but rather a download page. That's not going to work.

Pulling the URL that actually gets generated from the download (actually annoying to get, as it is all javascripty, but at least stable) yields:

https://doc-00-ag-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/l058tmm4stdqdjhe1hs0t564snj08ahm/c?e=download

And feeding that into the front page of nbviewer, we get the nbviewer URL:
http://nbviewer.ipython.org/urls/doc-00-ag-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/l058tmm4stdqdjhe1hs0t564snj08ahm/1426680000000/09083926091300078733/*/0B30Cah_MN0i0TlZfRlBXLWgxbE

we are getting a 403: forbidden from the upstream provider.

Checking this with curl:

curl "https://doc-00-ag-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/l058tmm4stdqdjhe1hs0t564snj08ahm/1426680000000/09083926091300078733/*/0B30Cah_MN0i0TlZfRlBXLWgxbE0?e=download"

Shows the URL will actually reply, but just not to nbviewer.ipython.org.

So basically, we would either need:

  • google to allow nbviewer to request unauthenticated files
    • which they are unlikely to do, and would not be ultimately very useful, because a notebook without related assets is not very useful, and at present I doubt that any associated images, etc. would be addressable by a normal URL scheme.
  • a new provider for google drive, and use the API itself to retrieve public files

The provider option seems like a good idea, along with #371 (gitlab), #302 (webgit), and #402 (stash/bitbucket). I've included this in #428!

@dominikandreas
Copy link

Google Drive has worked for me in the past using the web host feature:
https://support.google.com/drive/answer/2881970?hl=en

You just need to extract the document id from the sharing link and use this address instead:
www.googledrive.com/host/[doc id]

Example: your sharing link https://drive.google.com/open?id=0BxSDFsdFDFTVU
results in www.googledrive.com/host/0BxSDFsdFDFTVU

For some reason however, this doesn't work any more. I'm getting the error "Error reading JSON notebook" . I think the notebook I tested should work (works in ipython), but I'll try again with another one soon.

@bollwyvl
Copy link
Contributor

None of those links appear to work, asking me to authenticate: try it in a
private browsing. Likely, nbviewer is getting back the HTML for the login
page.

Additionally, even if we did allow this, we would get throttled... one HN
post to something on GD, and poof! everyone's stuff becomes unreachable.

API-level integration is really the only path that makes any sense in the
long run vs google: they can (and have) changed their user URLs at any
time, whereas the APIs stay stable for at least a while, and they have a
fairly manageable sunset period between versions.

On Mon, Jul 27, 2015 at 1:00 PM dominikandreas [email protected]
wrote:

Google Drive has worked for me in the past using the web host feature:
https://support.google.com/drive/answer/2881970?hl=en

You just need to extract the document id from the sharing link and use
this address instead:
www.googledrive.com/host/[doc http://www.googledrive.com/host/%5Bdoc
id]

Example: your sharing link https://drive.google.com/open?id=0BxSDFsdFDFTVU
results in www.googledrive.com/host/0BxSDFsdFDFTVU

For some reason however, this doesn't work any more. I'm getting the error "Error
reading JSON notebook"
. I think the notebook I tested should work
(works in ipython), but I'll try again with another one soon.


Reply to this email directly or view it on GitHub
#427 (comment).

@onemandivision
Copy link

Those links were just an example (i made up the id). The webpage hosting feature of google drive should work though, it's made for static file serving. If nbviewer would catch the doc id from the sharing link and use the www.googledrive.com/host/[doc id] link instead, it shouldn't be a problem.

On the other hand, API-level integration is probably still the better way to go

@bollwyvl
Copy link
Contributor

Those links were just an example (i made up the id).

Tricky! I guess i was being too sneaky before.

here's the original julia notebook uploaded to my drive and set to share with world... preliminary effort suggests that setting it to the equivalent of a secret gist (i.e. no auth required, but not searchable) has no effect.

We could do something like this knock-off of the dropbox "provider":

# ./providers/gdrive/handlers.py
def uri_rewrites(rewrites=[]):
    return rewrites + [
        (r'^https://drive.google.com/file/d/([^/]*)/.*$',
            u'/urls/googledrive.com/host/{1}'),
        (r'^https://drive.google.com/open?id=([^&]*)$',
            u'/urls/googledrive.com/host/{1}'
    ]

Those two url patterns come through different techniques, both user accessible, but are different enough to not fit in one pattern.

I can guarantee that relative file links won't work: drive barely has directories as it is, but if people thought even this level of integration was useful, I wouldn't be against adding it...

@Sisyphuss
Copy link
Author

I agree that we should use stable API. As an occasional user of Google Drive, I noticed that Google constantly changes its interface to improve user experience.

bollwyvl added a commit to bollwyvl/nbviewer that referenced this issue Jul 29, 2015
@drorata
Copy link

drorata commented Feb 1, 2016

Is there any update on this one? We have google drive at work and I want to share notebooks inside the organization using a in-house hosted nbviewer.... It doesn't work at the moment.

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 1, 2016

Glad to here you are able to use nbviewer internally! We're always interested in feedback from other operators :)

I'm actually in the same boat: it would be lovely to share our private stuff on a local nbviewer.

For non-public drive content, one would have to build out a full API provider, with the server having its own API key able to see everything your google drive organization. The initial hack proposed would have just gotten the globally-viewable stuff.

Unfortunately, features that won't be used on nbviewer.*.org are likely not going to end up getting prioritized, but we do have an extension mechanism for providers that would allow an exension, i.e. nbviewer-gdrive, to be developed and used with nbviewer. Looks like there is now a v3 of the google REST API that would be a good target. We'd be happy to provide support to anyone that would like to embark on this journey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag:Provider Related to a notebook provider type:Enhancement A proposed extension to the behavior of the project
Projects
None yet
Development

No branches or pull requests

5 participants