Skip to content

Commit

Permalink
Merge pull request #21 from yuvipanda/hub-work
Browse files Browse the repository at this point in the history
Use default user token when running under JupyterHub
  • Loading branch information
jtpio committed Nov 19, 2021
2 parents 1c71b79 + 7aaae98 commit 526163e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ const plugin: JupyterFrontEndPlugin<void> = {
commands.addCommand(CommandIDs.share, {
label: trans.__('Share Jupyter Server Link'),
execute: async () => {
const results: { token: string }[] = await requestAPI<any>('servers');
let results: { token: string }[];
if (PageConfig.getOption('hubUser') !== '') {
// We are running on a JupyterHub, so let's just use the token set in PageConfig.
// Any extra servers running on the server will still need to use this token anyway,
// as all traffic (including any to jupyter-server-proxy) needs this token.
results = [{ token: PageConfig.getToken() }];
} else {
results = await requestAPI<any>('servers');
}

const links = results.map(server => {
return URLExt.normalize(
Expand Down

0 comments on commit 526163e

Please sign in to comment.