awacke1 commited on
Commit
5dbf73b
Β·
verified Β·
1 Parent(s): 5b73b95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
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 AzureCliCredential
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 = AzureCliCredential()
85
- ResourceManagementClient(credential, subscription_id)
 
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])