Created
March 14, 2018 03:46
-
-
Save hirokiky/fdd1b27bf68d00ecba5ae554bd666a0d to your computer and use it in GitHub Desktop.
tried to inject Authorization header for each request, but couldn't.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This way didn't work. | |
// Cause this custom.js or nbextensions files will be loaded after initializing JupyterNotebookApp. | |
// It means this code won't affect to it's initializing Ajax requests. | |
// Sending token on each XHRs too. | |
// Because Safari won't handle Cookie and localStorage | |
// on iframes. | |
// Jupyter Client expects it's cookie, so it will be forbidden | |
// Instead, sending "token" by manually on each XHRs. | |
// Retrieving token from data attribute | |
// Because Jupyter Notebook will delete ?token param automatically. | |
var token = document.querySelector('body').dataset.jupyterApiToken || ''; | |
jQuery.ajaxSetup({ | |
headers: {"Authorization": 'token ' + token} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment