Skip to content

Commit 6fd273e

Browse files
committed
UC external connections in Streamlit
1 parent 9cdb53f commit 6fd273e

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

streamlit/views/external_connections.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ def is_connection_login_error(error: str):
6767
return "Credential for user identity" in error and "Please login first to the connection" in error
6868

6969

70-
HTTP_METHODS = [
71-
{"label": "GET", "value": "GET"},
72-
{"label": "POST", "value": "POST"}
73-
]
74-
75-
AUTH_TYPES = [
76-
{"label": "Bearer token", "value": "bearer_token"},
77-
{"label": "OAuth User to Machine Per User", "value": "oauth_user_machine_per_user"},
78-
{"label": "OAuth Machine to Machine", "value": "oauth_machine_machine"}
79-
]
80-
81-
8270
st.header(body="External connections", divider=True)
8371
st.subheader("Securely call external API services")
8472
st.write(
@@ -96,14 +84,13 @@ def is_connection_login_error(error: str):
9684
connection_name = st.text_input("Connection Name", placeholder="Enter connection name...")
9785
auth_mode = st.radio(
9886
"Authentication Mode:",
99-
["Bearer token", "OAuth User to Machine Per User", "OAuth Machine to Machine"],
100-
help="Bearer token is the user token.",
87+
["Bearer token", "OAuth User to Machine Per User (On-behalf-of-user)", "OAuth Machine to Machine"],
10188
)
10289
http_method = st.selectbox("HTTP Method", options=["GET", "POST", "PUT", "DELETE", "PATCH"], )
10390
path = st.text_input("Path", placeholder="/api/endpoint")
10491
request_type = st.selectbox("Request Type", options=["Non-MCP", "MCP"])
105-
request_headers = st.text_area("Request headers", value='{"Content-Type": "application/json"}')
106-
request_data = st.text_area("Request data", value='{"key": "value"}')
92+
request_headers = st.text_area("Request headers", placeholder='{"Content-Type": "application/json"}')
93+
request_data = st.text_area("Request data", placeholder='{"key": "value"}')
10794

10895
all_fields_filled = path and connection_name != ""
10996
if not all_fields_filled:
@@ -113,7 +100,7 @@ def is_connection_login_error(error: str):
113100
if st.button("Send Request"):
114101
if auth_mode == "Bearer token":
115102
w = WorkspaceClient()
116-
elif auth_mode == "OAuth User to Machine Per User":
103+
elif auth_mode == "OAuth User to Machine Per User (On-behalf-of-user)":
117104
w = get_client_obo()
118105
elif auth_mode == "OAuth Machine to Machine":
119106
# TODO: Add OAuth Machine-to-Machine logic
@@ -156,8 +143,8 @@ def is_connection_login_error(error: str):
156143
conn=connection_name,
157144
method=http_method,
158145
path=path,
159-
headers=request_headers,
160-
json=request_data,
146+
headers=request_headers if request_headers else None,
147+
json=request_data if request_data else None,
161148
)
162149
st.subheader("Response")
163150
st.json(response.json())

0 commit comments

Comments
 (0)