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
|
@@ -81,8 +81,9 @@ if not st.session_state.logged_in:
|
|
81 |
subscription_id = st.text_input("Azure Subscription ID")
|
82 |
if st.button("π Login"):
|
83 |
try:
|
84 |
-
credential =
|
85 |
-
|
|
|
86 |
st.session_state.credential = credential
|
87 |
st.session_state.subscription_id = subscription_id
|
88 |
st.session_state.logged_in = True
|
@@ -90,6 +91,17 @@ if not st.session_state.logged_in:
|
|
90 |
st.rerun()
|
91 |
except Exception as e:
|
92 |
st.error(f"Failed to authenticate: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
else:
|
94 |
# Main app content
|
95 |
col1, col2 = st.columns([1, 3])
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import pandas as pd
|
4 |
+
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
|
5 |
from azure.mgmt.resource import ResourceManagementClient
|
6 |
from azure.cosmos import CosmosClient, exceptions
|
7 |
from github import Github
|
|
|
81 |
subscription_id = st.text_input("Azure Subscription ID")
|
82 |
if st.button("π Login"):
|
83 |
try:
|
84 |
+
credential = DefaultAzureCredential()
|
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
|
88 |
st.session_state.subscription_id = subscription_id
|
89 |
st.session_state.logged_in = True
|
|
|
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])
|