Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -731,8 +731,6 @@ def handle_onedrive_integration(access_token):
|
|
731 |
else:
|
732 |
st.error("Failed to delete file.")
|
733 |
|
734 |
-
|
735 |
-
|
736 |
def main():
|
737 |
st.title("π¦ MS Graph API with AI & Cloud Integration for M365")
|
738 |
|
@@ -751,7 +749,17 @@ def main():
|
|
751 |
st.sidebar.write(f"AI Capabilities: {details['ai_capabilities']}")
|
752 |
st.sidebar.write(f"Graph Solution: {details['graph_solution']}")
|
753 |
|
754 |
-
# Handle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
request_scopes = BASE_SCOPES.copy()
|
756 |
for product in selected_products:
|
757 |
request_scopes.extend(PRODUCT_SCOPES[product]['scopes'])
|
@@ -767,7 +775,7 @@ def main():
|
|
767 |
)
|
768 |
st.write('π Please [click here]({}) to log in and authorize the app.'.format(auth_url))
|
769 |
|
770 |
-
query_params = st.query_params
|
771 |
if 'code' in query_params:
|
772 |
code = query_params.get('code')
|
773 |
st.write('π Authorization Code Obtained:', code[:10] + '...')
|
@@ -776,7 +784,8 @@ def main():
|
|
776 |
access_token = get_access_token(code)
|
777 |
st.session_state['access_token'] = access_token
|
778 |
st.success("Access token acquired successfully!")
|
779 |
-
st.rerun
|
|
|
780 |
except Exception as e:
|
781 |
st.error(f"Error acquiring access token: {str(e)}")
|
782 |
st.stop()
|
@@ -787,9 +796,7 @@ def main():
|
|
787 |
if user_info:
|
788 |
st.sidebar.write(f"π Hello, {user_info.get('displayName', 'User')}!")
|
789 |
|
790 |
-
# Handle navigation based on the selected section
|
791 |
-
selected_section = st.experimental_get_query_params().get('section', ['dashboard'])[0]
|
792 |
-
|
793 |
if selected_section == 'dashboard':
|
794 |
dashboard(access_token)
|
795 |
elif selected_section == 'landing-page':
|
@@ -807,6 +814,7 @@ def main():
|
|
807 |
elif selected_section == 'filter-by':
|
808 |
filter_by(access_token)
|
809 |
|
|
|
810 |
if __name__ == "__main__":
|
811 |
main()
|
812 |
|
|
|
731 |
else:
|
732 |
st.error("Failed to delete file.")
|
733 |
|
|
|
|
|
734 |
def main():
|
735 |
st.title("π¦ MS Graph API with AI & Cloud Integration for M365")
|
736 |
|
|
|
749 |
st.sidebar.write(f"AI Capabilities: {details['ai_capabilities']}")
|
750 |
st.sidebar.write(f"Graph Solution: {details['graph_solution']}")
|
751 |
|
752 |
+
# Handle query parameters via session_state
|
753 |
+
if 'section' not in st.session_state:
|
754 |
+
st.session_state['section'] = 'dashboard' # Default section is the dashboard
|
755 |
+
|
756 |
+
selected_section = st.session_state['section']
|
757 |
+
|
758 |
+
# Example of re-running based on interaction (you can change sections)
|
759 |
+
if st.button("Go to Landing Page"):
|
760 |
+
st.session_state['section'] = 'landing-page'
|
761 |
+
|
762 |
+
# Request scopes and authentication management
|
763 |
request_scopes = BASE_SCOPES.copy()
|
764 |
for product in selected_products:
|
765 |
request_scopes.extend(PRODUCT_SCOPES[product]['scopes'])
|
|
|
775 |
)
|
776 |
st.write('π Please [click here]({}) to log in and authorize the app.'.format(auth_url))
|
777 |
|
778 |
+
query_params = st.session_state.get('query_params', {})
|
779 |
if 'code' in query_params:
|
780 |
code = query_params.get('code')
|
781 |
st.write('π Authorization Code Obtained:', code[:10] + '...')
|
|
|
784 |
access_token = get_access_token(code)
|
785 |
st.session_state['access_token'] = access_token
|
786 |
st.success("Access token acquired successfully!")
|
787 |
+
# No need for st.experimental_rerun; changing session state triggers rerun
|
788 |
+
st.session_state['section'] = 'dashboard'
|
789 |
except Exception as e:
|
790 |
st.error(f"Error acquiring access token: {str(e)}")
|
791 |
st.stop()
|
|
|
796 |
if user_info:
|
797 |
st.sidebar.write(f"π Hello, {user_info.get('displayName', 'User')}!")
|
798 |
|
799 |
+
# Handle navigation based on the selected section
|
|
|
|
|
800 |
if selected_section == 'dashboard':
|
801 |
dashboard(access_token)
|
802 |
elif selected_section == 'landing-page':
|
|
|
814 |
elif selected_section == 'filter-by':
|
815 |
filter_by(access_token)
|
816 |
|
817 |
+
|
818 |
if __name__ == "__main__":
|
819 |
main()
|
820 |
|