Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
-
from azure.identity import
|
5 |
from azure.mgmt.resource import ResourceManagementClient
|
6 |
from azure.cosmos import CosmosClient, exceptions
|
7 |
from github import Github
|
@@ -78,10 +78,17 @@ if 'logged_in' not in st.session_state:
|
|
78 |
# Login section
|
79 |
if not st.session_state.logged_in:
|
80 |
st.subheader("π Login")
|
|
|
|
|
|
|
81 |
subscription_id = st.text_input("Azure Subscription ID")
|
82 |
if st.button("π Login"):
|
83 |
try:
|
84 |
-
credential =
|
|
|
|
|
|
|
|
|
85 |
# Try to get a token to verify the credential works
|
86 |
credential.get_token("https://management.azure.com/.default")
|
87 |
st.session_state.credential = credential
|
@@ -91,17 +98,6 @@ if not st.session_state.logged_in:
|
|
91 |
st.rerun()
|
92 |
except Exception as e:
|
93 |
st.error(f"Failed to authenticate: {str(e)}")
|
94 |
-
st.info("If you're in a browser environment, try using InteractiveBrowserCredential")
|
95 |
-
try:
|
96 |
-
credential = InteractiveBrowserCredential()
|
97 |
-
credential.get_token("https://management.azure.com/.default")
|
98 |
-
st.session_state.credential = credential
|
99 |
-
st.session_state.subscription_id = subscription_id
|
100 |
-
st.session_state.logged_in = True
|
101 |
-
st.success("Successfully logged in using InteractiveBrowserCredential!")
|
102 |
-
st.rerun()
|
103 |
-
except Exception as e:
|
104 |
-
st.error(f"Failed to authenticate with InteractiveBrowserCredential: {str(e)}")
|
105 |
else:
|
106 |
# Main app content
|
107 |
col1, col2 = st.columns([1, 3])
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
+
from azure.identity import ClientSecretCredential
|
5 |
from azure.mgmt.resource import ResourceManagementClient
|
6 |
from azure.cosmos import CosmosClient, exceptions
|
7 |
from github import Github
|
|
|
78 |
# Login section
|
79 |
if not st.session_state.logged_in:
|
80 |
st.subheader("π Login")
|
81 |
+
tenant_id = st.text_input("Azure Tenant ID")
|
82 |
+
client_id = st.text_input("Azure Client ID")
|
83 |
+
client_secret = st.text_input("Azure Client Secret", type="password")
|
84 |
subscription_id = st.text_input("Azure Subscription ID")
|
85 |
if st.button("π Login"):
|
86 |
try:
|
87 |
+
credential = ClientSecretCredential(
|
88 |
+
tenant_id=tenant_id,
|
89 |
+
client_id=client_id,
|
90 |
+
client_secret=client_secret
|
91 |
+
)
|
92 |
# Try to get a token to verify the credential works
|
93 |
credential.get_token("https://management.azure.com/.default")
|
94 |
st.session_state.credential = credential
|
|
|
98 |
st.rerun()
|
99 |
except Exception as e:
|
100 |
st.error(f"Failed to authenticate: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
else:
|
102 |
# Main app content
|
103 |
col1, col2 = st.columns([1, 3])
|