GuglielmoTor commited on
Commit
896ae69
·
verified ·
1 Parent(s): 03af851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -1,17 +1,28 @@
1
  import gradio as gr
 
2
  from Data_Fetching_and_Rendering import fetch_org_urn
3
 
4
  # shared state
5
  token_received = {"status": False, "token": "", "client_id": ""}
6
 
7
  # 1) this will be called by POST
8
- def receive_token(accessToken: dict, client_id: str):
 
 
 
 
 
 
 
 
 
 
9
  token_received["status"] = True
10
- token_received["token"] = accessToken
11
  token_received["client_id"] = client_id
12
  return {
13
  "status": "✅ Code received",
14
- "token": accessToken,
15
  "client_id": client_id
16
  }
17
 
 
1
  import gradio as gr
2
+ import json
3
  from Data_Fetching_and_Rendering import fetch_org_urn
4
 
5
  # shared state
6
  token_received = {"status": False, "token": "", "client_id": ""}
7
 
8
  # 1) this will be called by POST
9
+ def receive_token(accessToken: str, client_id: str):
10
+ try:
11
+ token_dict = json.loads(accessToken.replace("'", '"')) # crude but works if trusted input
12
+ except json.JSONDecodeError as e:
13
+ print("Failed to parse accessToken:", e)
14
+ return {
15
+ "status": "❌ Invalid token format",
16
+ "token": "",
17
+ "client_id": client_id
18
+ }
19
+
20
  token_received["status"] = True
21
+ token_received["token"] = token_dict
22
  token_received["client_id"] = client_id
23
  return {
24
  "status": "✅ Code received",
25
+ "token": token_dict.get("access_token", ""),
26
  "client_id": client_id
27
  }
28