Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,8 +43,35 @@ else:
|
|
| 43 |
# Create the MSAL instance for acquiring tokens
|
| 44 |
client_instance = get_msal_app()
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Now this function accepts both 'code' and 'code_verifier'
|
| 47 |
-
def
|
| 48 |
client_instance = get_msal_app()
|
| 49 |
|
| 50 |
st.write("Debug: MSAL App Configuration:")
|
|
|
|
| 43 |
# Create the MSAL instance for acquiring tokens
|
| 44 |
client_instance = get_msal_app()
|
| 45 |
|
| 46 |
+
def get_access_token(code):
|
| 47 |
+
client_instance = get_msal_app()
|
| 48 |
+
|
| 49 |
+
st.write("Debug: MSAL App Configuration:")
|
| 50 |
+
st.write(f"Client ID: {APPLICATION_ID_KEY[:5]}...")
|
| 51 |
+
st.write(f"Authority: {AUTHORITY_URL}")
|
| 52 |
+
st.write(f"Redirect URI: {REDIRECT_URI}")
|
| 53 |
+
|
| 54 |
+
try:
|
| 55 |
+
# Without code_verifier (for testing)
|
| 56 |
+
result = client_instance.acquire_token_by_authorization_code(
|
| 57 |
+
code=code,
|
| 58 |
+
scopes=SCOPES,
|
| 59 |
+
redirect_uri=REDIRECT_URI
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
if 'access_token' in result:
|
| 63 |
+
return result['access_token']
|
| 64 |
+
else:
|
| 65 |
+
error_description = result.get('error_description', 'No error description provided')
|
| 66 |
+
raise Exception(f"Error acquiring token: {error_description}")
|
| 67 |
+
except Exception as e:
|
| 68 |
+
st.error(f"Exception in get_access_token: {str(e)}")
|
| 69 |
+
raise
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
# Now this function accepts both 'code' and 'code_verifier'
|
| 74 |
+
def get_access_token2(code, code_verifier=None):
|
| 75 |
client_instance = get_msal_app()
|
| 76 |
|
| 77 |
st.write("Debug: MSAL App Configuration:")
|