How to share Google Colab notebook with limited permissions

Viewed 7078

I want to share a Colab notebook online with two things that are important to me: 1. Viewers can run the cells 2. Viewers are not allowed to save or mess with the code

I saw some projects that were published like that but was not able to find a solution on my own. Any suggestions?

3 Answers

You can use this URL format:

https://colab.research.google.com/drive/{EXAMPLE}#offline=true&sandboxMode=true

Replace the {EXAMPLE} with your own FILE_ID.

They can run the notebook. They cannot change or save to your file, but they can copy, change, and save in their own Drive.

To prevent editing a notebook, share it with view only permission just as you would any other Drive document.

There's no way to share a notebook with a user and prevent them from viewing the code.

Code is stored in the notebook JSON and, even when hidden in the UI, is available to sophisticated users who can do things like inspect the network requests in the browser developer console.

Inside the "share" button at the top right corner of your colab notebook, you can see a "get link" option at the bottom, and a hyperlink of "change" below the "get link".

Click the "change" hyperlink and you can choose anyone("anyone" literally means unspecified person(s) on the internet) with the link as viewer,commentor or editor.

By changing that to "viewer", anyone on the internet can open your colab file without asking for your permission, at the same time the change(s) they made in the notebook will not be saved.

If they want to run your code, they can open a new colab notebook, then copy and paste your code on it, and run. So nothing in your original notebook will be messed up.

Related