Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

Drive API - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Wiki source code of Drive API

Version 5.1 by hbpadmin on 2020/10/12 12:19

Show last authors
1 == Abstract ==
2
3 The Collaboratory is using seafile as storage on [[drive.ebrains.eu>>https://drive.ebrains.eu/]]
4
5 (% class="wikigeneratedid" %)
6 In this tutorial you will found usefull link to help you to interact with the drive from your notebooks or apps.
7
8
9 == The ebrains-drive library ==
10
11 HBP and CNRS are working on a python library to access drive feature from python code (including notebooks)
12
13 * **github :** [[https:~~/~~/github.com/HumanBrainProject/ebrains-drive>>https://github.com/HumanBrainProject/ebrains-drive]]
14 * **documentation : **[[https:~~/~~/github.com/HumanBrainProject/ebrains-drive/blob/master/doc.md>>https://github.com/HumanBrainProject/ebrains-drive/blob/master/doc.md]]
15 * **live exemple in notebook lab : {{jupyterlink}}https://lab.ebrains.eu/user/messines/lab/tree/drive/Shared%20with%20groups/The%20Collaboratory/Tutorial/DriveAPI_Sample.ipynb{{/jupyterlink}}**
16
17 == The seafile official REST API ==
18
19 * **Officiel documentation :** [[https:~~/~~/seafile.gitbook.io/seafile-server-manual/developing/web-api#library>>https://seafile.gitbook.io/seafile-server-manual/developing/web-api#library]]
20
21 (% class="wikigeneratedid" %)
22 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.
23
24 {{code}}
25 import ebrains_drive
26 from ebrains_drive.client import DriveApiClient
27
28 bearer_token = clb_oauth.get_token()
29 client = ebrains_drive.connect(token=bearer_token)
30 account_info = client.get('/api2/account/info/').json()
31 {{/code}}
32
33 == Authentication from python code with username/password ==
34
35 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
36
37 {{code}}
38 import ebrains_drive
39 from ebrains_drive.client import DriveApiClient
40
41 bearer_token = clb_oauth.get_token()
42 client = ebrains_drive.connect(token=bearer_token)
43 {{/code}}
44
45
46 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.
47
48 {{code}}
49 client = ebrains_drive.connect(username="username", password="password")
50 {{/code}}
51
52 This connect function use the validation client created by CNRS. [[https:~~/~~/validation-v2.brainsimulation.eu/login   >>https://validation-v2.brainsimulation.eu/]]
53
54 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.