Metadata-Version: 2.1
Name: swanoauthrenew
Version: 1.0.2
Summary: Extension that renews an OAuth2 token
Home-page: https://github.com/swan-cern/jupyter-extensions
Author: SWAN Admins
License: AGPL-3.0
Keywords: Jupyter,Notebooks,SWAN,CERN
Platform: Linux
Platform: Mac OS X
Platform: Windows
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Framework :: Jupyter
Description-Content-Type: text/markdown
Requires-Dist: jupyter_server
Requires-Dist: requests
Requires-Dist: PyJWT

# SwanOauthRenew

This is a server extension that fetches the oAuth tokens available in the "user" endpoint of the JupyterHub API (1) and stores them in files that can be accessed by other processes (like the EOS client). It can be configured to take any token from the auth state dictionary and write it with any content format.

(1) For now, this functionality is exclusive to SwanHub (our JH wrapper). It does not work on vanilla JH, as the auth state is only available to admins.

## Requirements

* notebook

## Install

```bash
pip install swanoauthrenew
```

## Usage

Configure the server extension to load when the notebook server starts

```bash
 jupyter serverextension enable --py --user swanoauthrenew
```

Then is necessary to configure (in the jupyter config file) the files that need to be written, from where the tokens are coming from and how the file content should look like. Like so:

```python
c.SwanOauthRenew.files = [
        ('/tmp/swan_oauth.token', 'access_token', '{token}'),
        ('/tmp/cernbox_oauth.token', 'exchanged_tokens/cernbox-service', '{token}'),
        ('/tmp/eos_oauth.token', 'exchanged_tokens/eos-service', 'oauth2:{token}:auth.cern.ch')
    ]
```
