Skip to content

Commit fc8baef

Browse files
committed
add auth with credentials
1 parent c5b593b commit fc8baef

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@ from nocodb.infra.requests_client import NocoDBRequestsClient
1414

1515
# Usage with API Token
1616
client = NocoDBRequestsClient(
17+
# Your nocodb root path
18+
"http://localhost:8080",
1719
# Your API Token retrieved from NocoDB conf
1820
APIToken("YOUR-API-TOKEN"),
19-
# Your nocodb root path
20-
"http://localhost:8080"
2121
)
2222

2323
# Usage with JWT Token
2424
client = NocoDBRequestsClient(
25+
# Your nocodb root path
26+
"http://localhost:8080",
2527
# Your API Token retrieved from NocoDB conf
2628
JWTAuthToken("your.jwt.token"),
29+
)
30+
31+
# Usage with email and password
32+
client = NocoDBRequestsClient(
2733
# Your nocodb root path
28-
"http://localhost:8080"
34+
"http://localhost:8080",
35+
# Your profile credentials
36+
37+
password="123qwe123!"
2938
)
3039
```
3140

nocodb/api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44

55
class NocoDBAPIUris(Enum):
66
V1_DB_DATA_PREFIX = "api/v1/db/data"
7+
V1_AUTH_USER_PREFIX = "api/v1/auth/user"
78

89

910
class NocoDBAPI:
1011
def __init__(self, base_uri: str):
1112
self.__base_data_uri = (
1213
f"{base_uri}/{NocoDBAPIUris.V1_DB_DATA_PREFIX.value}"
1314
)
15+
self.__base_auth_uri = (
16+
f"{base_uri}/{NocoDBAPIUris.V1_AUTH_USER_PREFIX.value}"
17+
)
18+
def get_auth_uri(self):
19+
return "/".join(
20+
(
21+
self.__base_auth_uri,
22+
"signin"
23+
)
24+
)
1425

1526
def get_table_uri(self, project: NocoDBProject, table: str) -> str:
1627
return "/".join(

0 commit comments

Comments
 (0)