You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace password auth with a browser-based device authorization flow and persistent token caching (~/.config/brainstem/token). Export AuthenticationError and modernize BrainstemClient: session-backed requests, unified load/save/delete methods, auto-pagination (load_all), query param handling (filters/sort/include/limit/offset), model→app routing table, and many convenience loaders (load_project/subject/session/... ). Add a command-line interface (brainstem entrypoint), update README and tutorial for new usage, add pyproject.toml (remove setup.py), and include comprehensive unit tests for client behavior and auth flow.
Copy file name to clipboardExpand all lines: README.md
+135-6Lines changed: 135 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,157 @@ You can install the package using `pip`:
8
8
pip install brainstem_python_api_tools
9
9
```
10
10
11
+
## Authentication
12
+
13
+
Authentication uses a **browser-based device authorization flow** that supports two-factor authentication (2FA). No credentials are entered into the tool itself.
14
+
15
+
```python
16
+
from brainstem_api_tools import BrainstemClient
17
+
18
+
# First run: opens a browser window for secure login.
19
+
# The token is cached at ~/.config/brainstem/token and reused automatically.
20
+
client = BrainstemClient()
21
+
```
22
+
23
+
To skip the browser flow, pass a token directly:
24
+
```python
25
+
client = BrainstemClient(token="YOUR_TOKEN")
26
+
```
27
+
28
+
For headless environments (no browser available):
29
+
```python
30
+
client = BrainstemClient(headless=True) # prints a URL + code to enter manually
31
+
```
32
+
33
+
To connect to a different server (e.g. a local development instance):
> **Security note:** The cached token file is stored with owner-read-only permissions (`0600`). Treat it like a password and do not commit it to version control.
39
+
11
40
## Getting Started
12
41
To get started with the BrainSTEM API tools, please refer to the tutorial script provided:
13
42
14
43
-**Tutorial:**`brainstem_api_tutorial.py`
15
44
16
45
The tutorial demonstrates how to:
17
46
18
-
-**Authenticate:** Load the client and authenticate using your credentials.
19
-
-**Loading Data:** Load sessions and filter data using flexible options.
20
-
-**Updating Entries:** Modify existing models and update them in the database.
21
-
-**Creating Entries:** Submit new data entries with required fields.
22
-
-**Loading Public Data:** Access public projects and data using the public portal.
47
+
-**Authenticate:** Load the client and authenticate via your browser.
48
+
-**Load Data:** Load sessions and filter data using flexible options.
49
+
-**Paginate:** Retrieve large datasets using `limit` / `offset` or `load_all=True`.
50
+
-**Convenience Loaders:** Use `load_session()`, `load_subject()`, etc. for common queries.
51
+
-**Update Entries:** Modify existing records and update them in the database.
52
+
-**Create Entries:** Submit new data entries with required fields.
53
+
-**Delete Entries:** Remove records by ID.
54
+
-**Load Public Data:** Access public projects and data using the public portal.
0 commit comments