Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -171,30 +171,30 @@ def main():
|
|
171 |
# ๐ต๏ธโโ๏ธ Check for authorization code in query parameters
|
172 |
query_params = st.query_params
|
173 |
query = (query_params.get('code'))
|
174 |
-
if len(query) > 1:
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
-
st.write('
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
scopes=SCOPES,
|
194 |
-
redirect_uri=REDIRECT_URI
|
195 |
-
)
|
196 |
-
st.write('๐ Please [click here]({}) to log in and authorize the app.'.format(authorization_url))
|
197 |
-
st.stop()
|
198 |
|
199 |
|
200 |
else:
|
|
|
171 |
# ๐ต๏ธโโ๏ธ Check for authorization code in query parameters
|
172 |
query_params = st.query_params
|
173 |
query = (query_params.get('code'))
|
174 |
+
#if len(query) > 1:
|
175 |
+
|
176 |
+
st.write('Parsing query ' + query_params )
|
177 |
+
if 'code' in query_params:
|
178 |
+
#code = query_params['code'][0]
|
179 |
+
code = query_params.get('code')
|
180 |
|
181 |
+
st.write('๐Access Code Obtained from MS Graph Redirect๐!:' + code)
|
182 |
+
|
183 |
+
st.write('๐ Acquiring access token from redirect URL for code parameter.')
|
184 |
+
access_token = get_access_token(code)
|
185 |
+
|
186 |
+
st.session_state['access_token'] = access_token # ๐ Save it for later
|
187 |
+
|
188 |
+
st.rerun() # Reload the app to clear the code from URL
|
189 |
+
else:
|
190 |
+
# ๐ข Prompt user to log in
|
191 |
+
client_instance = get_msal_app()
|
192 |
+
authorization_url = client_instance.get_authorization_request_url(
|
193 |
+
scopes=SCOPES,
|
194 |
+
redirect_uri=REDIRECT_URI
|
195 |
+
)
|
196 |
+
st.write('๐ Please [click here]({}) to log in and authorize the app.'.format(authorization_url))
|
197 |
+
st.stop()
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
|
200 |
else:
|