Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
import streamlit as st
|
| 3 |
import requests
|
| 4 |
import msal
|
|
|
|
| 5 |
|
| 6 |
# ๐ค Load environment variables (Ensure these are set!)
|
| 7 |
APPLICATION_ID_KEY = os.getenv('APPLICATION_ID_KEY')
|
|
@@ -25,16 +26,29 @@ def get_msal_app():
|
|
| 25 |
# ๐ Acquire access token using authorization code
|
| 26 |
def get_access_token(code):
|
| 27 |
client_instance = get_msal_app()
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def process_query_parms():
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import requests
|
| 4 |
import msal
|
| 5 |
+
import urllib.parse
|
| 6 |
|
| 7 |
# ๐ค Load environment variables (Ensure these are set!)
|
| 8 |
APPLICATION_ID_KEY = os.getenv('APPLICATION_ID_KEY')
|
|
|
|
| 26 |
# ๐ Acquire access token using authorization code
|
| 27 |
def get_access_token(code):
|
| 28 |
client_instance = get_msal_app()
|
| 29 |
+
|
| 30 |
+
# Debug: Print MSAL app configuration (be careful not to expose secrets)
|
| 31 |
+
st.write("Debug: MSAL App Configuration:")
|
| 32 |
+
st.write(f"Client ID: {APPLICATION_ID_KEY[:5]}...") # Show first 5 chars
|
| 33 |
+
st.write(f"Authority: {AUTHORITY_URL}")
|
| 34 |
+
st.write(f"Redirect URI: {REDIRECT_URI}")
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
result = client_instance.acquire_token_by_authorization_code(
|
| 38 |
+
code=code,
|
| 39 |
+
scopes=SCOPES,
|
| 40 |
+
redirect_uri=REDIRECT_URI
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if 'access_token' in result:
|
| 44 |
+
return result['access_token']
|
| 45 |
+
else:
|
| 46 |
+
error_description = result.get('error_description', 'No error description provided')
|
| 47 |
+
raise Exception(f"Error acquiring token: {error_description}")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
st.error(f"Exception in get_access_token: {str(e)}")
|
| 50 |
+
raise
|
| 51 |
+
#st.stop()
|
| 52 |
|
| 53 |
|
| 54 |
def process_query_parms():
|