Spaces:
Runtime error
Runtime error
Commit
Β·
291ad35
1
Parent(s):
1921e7a
feat: resvoled token to org config
Browse files
src/distilabel_dataset_generator/utils.py
CHANGED
|
@@ -42,15 +42,17 @@ def list_orgs(oauth_token: OAuthToken = None):
|
|
| 42 |
if oauth_token is None:
|
| 43 |
return []
|
| 44 |
data = whoami(oauth_token.token)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
def get_org_dropdown(oauth_token: OAuthToken = None):
|
|
|
|
| 42 |
if oauth_token is None:
|
| 43 |
return []
|
| 44 |
data = whoami(oauth_token.token)
|
| 45 |
+
if data["auth"]["type"] == "oauth":
|
| 46 |
+
organisations = [data["name"]] + [org["name"] for org in data["orgs"]]
|
| 47 |
+
else:
|
| 48 |
+
organisations = [
|
| 49 |
+
entry["entity"]["name"]
|
| 50 |
+
for entry in data["auth"]["accessToken"]["fineGrained"]["scoped"]
|
| 51 |
+
if "repo.write" in entry["permissions"]
|
| 52 |
+
]
|
| 53 |
+
organisations = [org for org in organisations if org != data["name"]]
|
| 54 |
+
organisations = [data["name"]] + organisations
|
| 55 |
+
return organisations
|
| 56 |
|
| 57 |
|
| 58 |
def get_org_dropdown(oauth_token: OAuthToken = None):
|