Drive API
Abstract
The Collaboratory is using seafile as storage on drive.ebrains.eu
In this tutorial you will found usefull link to help you to interact with the drive from your notebooks or apps.
The ebrains-drive library
HBP and CNRS are working on a python library to access drive feature from python code (including notebooks)
- github : https://github.com/HumanBrainProject/ebrains-drive
- documentation : https://github.com/HumanBrainProject/ebrains-drive/blob/master/doc.md
- live exemple in notebook lab : https://lab.ebrains.eu/user-redirect/lab/tree/drive/Shared%20with%20groups/The%20Collaboratory/Tutorial/DriveAPI_Sample.ipynb
The seafile official REST API
- Officiel documentation : https://seafile.gitbook.io/seafile-server-manual/developing/web-api#library
The seafile official rest API provide all the existing endpoint and function usable in seafile. Our library ebrains-drive just simplify its usage by creating specific Collaboratory endpoints. But if you don't found what you need in ebrains-drive function, you can perfectly use ebrains-drive to reach the original API like in this exemple.
from ebrains_drive.client import DriveApiClient
bearer_token = clb_oauth.get_token()
client = ebrains_drive.connect(token=bearer_token)
account_info = client.get('/api2/account/info/').json()
Authentication from python code with username/password
If you are in a notebook environement inside our lab. You should avoid enter any username or password to login with the seafile API. You should process as in the notebook exemple above and use
from ebrains_drive.client import DriveApiClient
bearer_token = clb_oauth.get_token()
client = ebrains_drive.connect(token=bearer_token)
But if you are trying to access drive API from outside our environement, you can use the client created by CNRS and login with your password and credentials.
This connect function use the validation client created by CNRS. https://validation-v2.brainsimulation.eu/login
It currently require a Collaboratory 1 account but this should change soon. But this function should not be consider as the standart workflow, it will probably change in the futur as it's not host by The Collaboratory.