Spaces:
Sleeping
Sleeping
Update app_web.py
Browse files- app_web.py +3 -1
app_web.py
CHANGED
|
@@ -19,18 +19,20 @@ snapshot_download(repo_id="CGIAR/weai-kb",
|
|
| 19 |
|
| 20 |
def cg_admin():
|
| 21 |
headers = st.context.headers
|
|
|
|
| 22 |
if "X-Forwarded-User" in headers:
|
| 23 |
username = headers.get("X-Forwarded-User")
|
| 24 |
token = headers.get("X-Forwarded-Access-Token")
|
| 25 |
userinfo_url = "https://huggingface.co/oauth/userinfo"
|
| 26 |
response = requests.get(userinfo_url, headers={"Authorization": f"Bearer {token}"})
|
| 27 |
-
|
| 28 |
if response.status_code == 200:
|
| 29 |
user_data = response.json()
|
| 30 |
|
| 31 |
# 3. Extract and display the list of organizations
|
| 32 |
# The 'orgs' list contains objects with organization details (name, role, etc.)
|
| 33 |
orgs = user_data.get("orgs", [])
|
|
|
|
| 34 |
|
| 35 |
if "CGIAR" in [org.get("name") for org in orgs]:
|
| 36 |
return True
|
|
|
|
| 19 |
|
| 20 |
def cg_admin():
|
| 21 |
headers = st.context.headers
|
| 22 |
+
print(headers)
|
| 23 |
if "X-Forwarded-User" in headers:
|
| 24 |
username = headers.get("X-Forwarded-User")
|
| 25 |
token = headers.get("X-Forwarded-Access-Token")
|
| 26 |
userinfo_url = "https://huggingface.co/oauth/userinfo"
|
| 27 |
response = requests.get(userinfo_url, headers={"Authorization": f"Bearer {token}"})
|
| 28 |
+
print(username, token)
|
| 29 |
if response.status_code == 200:
|
| 30 |
user_data = response.json()
|
| 31 |
|
| 32 |
# 3. Extract and display the list of organizations
|
| 33 |
# The 'orgs' list contains objects with organization details (name, role, etc.)
|
| 34 |
orgs = user_data.get("orgs", [])
|
| 35 |
+
print(orgs)
|
| 36 |
|
| 37 |
if "CGIAR" in [org.get("name") for org in orgs]:
|
| 38 |
return True
|