We are trying to set up a task so that we can submit a job to the Neuromorphic platform API and / or the HPC platform. This will then put the results in the document service (I believe that this is accessible from the task API). To do either of these things requires an OIDC access token.

Ok, I see now.Yes, document service API is accessible through interface I posted earlier.We will have to extend the interface to provide method to retrieve token.I can provide you workaround for now in case it is urgent.

Hi Yuri,I am currently using our own Jupyter notebook installation with OAuth2 module installed, I need to get the OAuth2 token form the nb console as I authenticate, but anyway I have some problem with token expiration.

The function you are looking for is not in the hbp-service-client, but in the now deprecated bbp-service-client. That package is still present in the Notebooks in the Collaboratory for compatibility reasons.

The method in question was doing one of the OIDC Authentication flows, which you can also do yourself. Some documentation:

Thanks for the answer,anyway my problem remains how to pass the token to the Jupyter collab after first authentication on JuyterHub.The first token expires as soon as the expiration time has been passed, the problem arise mostly because there's no way to pass the OAuth2 new token from the JupyterHub server authentication method to the Jupyter console (this can be don only once after the spanwer process has been started the first time, pre_spawner_start() method).

In order to obtain a brand new token I should force the user to authenticate again i.e. inside the Jupyter console, after authenticating first with the Jupyter OAuth2 module.

Since the first token expire I cannot refresh anything and I cannot ask the user to authenticate twice inside the Jupyter.

So again, how is possible from the HBP collaboratory that the OAuth2 first new token can be passed through the hbp_client method to the Jupyter notebook console?

anyway my problem remains how to pass the token to the Jupyter collab after first authentication on JuyterHub.

I am confused. You said you are using your own Jupyter installation, but you say "Jupyter collab'. Is the problem related to the JupyterHub service of the Collaboratory?

So again, how is possible from the HBP collaboratory that the OAuth2 first new token can be passed through the hbp_client method to the Jupyter notebook console?

I am not sure what do you mean. The hbp_client library does not print tokens, it rather takes one during instantiation. It is the deprecated bbp_client that does so, and I am unfamiliar with the implementation.

In general if you need to obtain new access tokens after their expiration you need a refresh token. I believe the bbp_client was also using a mechanism to exchange a refresh token to new access tokens.