Package: jupyterlab-github
JupyterLab GitHubA JupyterLab extension for accessing GitHub repositories.What this extension isWhen you install this extension, an additional filebrowser tab will be added
to the left area of JupyterLab. This filebrowser allows you to select GitHub
organizations and users, browse their repositories, and open the files in those
repositories. If those files are notebooks, you can run them just as you would
any other notebook. You can also attach a kernel to text files and run those.
Basically, you should be able to open any file in a repository that JupyterLab can handle.Here is a screenshot of the plugin opening this very file on GitHub:What this extension is notThis is not an extension that provides full GitHub access, such as
saving files, making commits, forking repositories, etc.
For it to be so, it would need to more-or-less reinvent the GitHub website,
which represents a huge increase in complexity for the extension.A note on rate-limitingThis extension has both a client-side component (that is, JavaScript that is bundled
with JupyterLab), and a server-side component (that is, Python code that is added
to the Jupyter server). This extensionwillwork with out the server extension,
with a major caveat: when making unauthenticated requests to GitHub
(as we must do to get repository data), GitHub imposes fairly strict rate-limits
on how many requests we can make. As such, you are likely to hit that limit
within a few minutes of work. You will then have to wait up to an hour to regain access.For that reason, we recommend that you take the time and effort to set up the server
extension as well as the lab extension, which will allow you to access higher rate-limits.
This process is described in theinstallationsection.PrerequisitesJupyterLab > 3.0A GitHub account for the server extensionInstallationAs discussed above, this extension has both a server extension and a lab extension.
Both extensions will be installed by default when installing from PyPI, but you may
have only lab extension installed if you used the Extension Manager in JupyterLab.We recommend completing the steps described below as to not be rate-limited.
The purpose of the server extension is to add GitHub credentials that you will need to acquire
fromhttps://github.com/settings/developers, and then to proxy your request to GitHub.For JupyterLab version older than 3 please see the instructions on the2.x branch.1. Installing both server and prebuilt lab extensionJupyterLab 4.xTo install the both the server extension and (prebuilt) lab extension, enter the following in your terminal:pipinstalljupyterlab-githubJupyterLab 3.xWe need to pin the extension version to3.0.1for making it work on the JupyterLab 3.x.pipinstall'jupyterlab-github==3.0.1'After restarting JupyterLab, the extension should work, and you can experience
the joys of being rate-limited first-hand!2. Getting your credentials from GitHubThere are two approaches to getting credentials from GitHub:
(1) you can get an access token, (2) you can register an OAuth app.
The second approach is not recommended, and will be removed in a future release.Getting an access token (recommended)You can get an access token by following these steps:Verifyyour email address with GitHub.Go to your account settings on GitHub and select "Developer Settings" from the left panel.On the left, select "Personal access tokens"Click the "Generate new token" button, and enter your password.Give the token a description, and check the "repo" scope box.Click "Generate token"You should be given a string which will be your access token.Remember that this token is effectively a password for your GitHub account.Do notshare it online or check the token into version control,
as people can use it to access all of your data on GitHub.Setting up an OAuth application (deprecated)This approach to authenticating with GitHub is deprecated, and will be removed in a future release.
New users should use the access token approach.
You can register an OAuth application with GitHub by following these steps:Log into your GitHub account.Go tohttps://github.com/settings/developersand select the "OAuth Apps" tab on the left.Click the "New OAuth App" button.Fill out a name, homepage URL, description, and callback URL in the form.
This extension does not actually use OAuth, so these values actuallydo not matter much,
you just need to enter them to register the application.Click the "Register application" button.You should be taken to a new page with the new application information.
If you see fields showing "Client ID" and "Client Secret", congratulations!
These are the strings we need, and you have successfuly set up the application.It is important to note that the "Client Secret" string is, as the name suggests, a secret.Do notshare this value online, as people may be able to use it to impersonate you on GitHub.3. Enabling and configuring the server extensionThe server extension will be enabled by default on new JupyterLab installations
if you installed it with pip. If you used Extension Manager in JupyterLab,
please uninstall the extension and install it again with the instructions from point (1).Confirm that the server extension is installed and enabled with:jupyterserverextensionlistyou should see the following:- Validating jupyterlab_github...
     jupyterlab_github 4.0.0 OKOn some older installations (e.g. old JupyterHub versions) which use jupyternotebookserver instead of the newjupyter-server, the extension needs to
show up on the legacyserverextensionslist (note: no space betweenserverandextension):jupyterserverextensionlistIf the extension is not enabled run:jupyterserverextensionenablejupyterlab_githubor if using the legacynotebookserver:jupyterserverextensionenablejupyterlab_githubYou now need to add the credentials you got from GitHub
to your server configuration file. Instructions for generating a configuration
file can be foundhere.
Once you have identified this file, add the following lines to it:c.GitHubConfig.access_token='< YOUR_ACCESS_TOKEN >'where "< YOUR_ACCESS_TOKEN >" is the string value you obtained above.
If you generated an OAuth app, instead enter the following:c.GitHubConfig.client_id='< YOUR_CLIENT_ID >'c.GitHubConfig.client_secret='< YOUR_CLIENT_SECRET >'where "< YOUR_CLIENT_ID >" and "< YOUR_CLIENT_SECRET >" are the app values you obtained above.With this, you should be done! Launch JupyterLab and look for the GitHub tab on the left!CustomizationYou can set the plugin to start showing a particular repository at launch time.
Open the "Advanced Settings" editor in the Settings menu,
and under the GitHub settings add{"defaultRepo":"owner/repository"}whereowneris the GitHub user/org,
andrepositoryis the name of the repository you want to open.