Using REST api to modify file

This might not be the correct use for the jupyter REST api, but I am trying to modify a notebook on jupyterlab from an extension. I am making the patch /api/contents/path_to_file.ipynb?token=123.

My issue is that I do not know how to get the authentication token programmatically. Is there a way to get the token from typescript in my extension?

Actually just solved it.

const settings= ServerConnection.makeSettings();
settings.token returns the token

1 Like

Note that using the ServerConnection.makeRequest can do a better job of consistently applying headers, etc. than manually constructing fetch arguments, etc.


Thanks for the suggestion. That does seem like a better way to do it.